r301218 - Pragma: Fix DebugOverflowStack() resulting in endless loop.

Matthias Braun via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 11:41:01 PDT 2017


Author: matze
Date: Mon Apr 24 13:41:00 2017
New Revision: 301218

URL: http://llvm.org/viewvc/llvm-project?rev=301218&view=rev
Log:
Pragma: Fix DebugOverflowStack() resulting in endless loop.

Drive-by fix (noticed while working on https://reviews.llvm.org/D32205):
DebugOverflowStack() is supposed to provoke a stack overflow, however
LLVM was smart enough to use the red-zone and fold the load into a tail
jump on x86_64 optimizing this to an endless loop instead of a stack
overflow.

Modified:
    cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=301218&r1=301217&r2=301218&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Mon Apr 24 13:41:00 2017
@@ -989,9 +989,9 @@ struct PragmaDebugHandler : public Pragm
 #ifdef _MSC_VER
     #pragma warning(disable : 4717)
 #endif
-  static void DebugOverflowStack() {
-    void (*volatile Self)() = DebugOverflowStack;
-    Self();
+  static void DebugOverflowStack(void (*P)() = nullptr) {
+    void (*volatile Self)(void(*P)()) = DebugOverflowStack;
+    Self(reinterpret_cast<void(*)()>(Self));
   }
 #ifdef _MSC_VER
     #pragma warning(default : 4717)




More information about the cfe-commits mailing list