]> granicus.if.org Git - clang/commitdiff
Pragma: Fix DebugOverflowStack() resulting in endless loop.
authorMatthias Braun <matze@braunis.de>
Mon, 24 Apr 2017 18:41:00 +0000 (18:41 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 24 Apr 2017 18:41:00 +0000 (18:41 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301218 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Pragma.cpp

index f81eaa31e9e99b0091f13c75d62cab9f5a841405..87e105d1d03d49fd226b6f3ba6b71a7e574d2d31 100644 (file)
@@ -989,9 +989,9 @@ struct PragmaDebugHandler : public PragmaHandler {
 #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)