[PATCH] Fix current stack unwinding when using DRASan

Timur Iskhodzhanov timurrrr at google.com
Fri Nov 29 04:34:23 PST 2013


Hi kcc, samsonov,

http://llvm-reviews.chandlerc.com/D2290

Files:
  asan_stack.h

Index: asan_stack.h
===================================================================
--- asan_stack.h
+++ asan_stack.h
@@ -34,17 +34,23 @@
   StackTrace stack;                                         \
   stack.Unwind(max_s, pc, bp, 0, 0, fast)
 #else
-#define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast)                \
-  StackTrace stack;                                                        \
-  {                                                                        \
-    AsanThread *t;                                                         \
-    stack.size = 0;                                                        \
-    if (asan_inited && (t = GetCurrentThread()) && !t->isUnwinding()) {    \
-      uptr stack_top = t->stack_top();                                     \
-      uptr stack_bottom = t->stack_bottom();                               \
-      ScopedUnwinding unwind_scope(t);                                     \
-      stack.Unwind(max_s, pc, bp, stack_top, stack_bottom, fast);          \
-    }                                                                      \
+#define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast)                    \
+  StackTrace stack;                                                            \
+  {                                                                            \
+    AsanThread *t;                                                             \
+    stack.size = 0;                                                            \
+    if (asan_inited) {                                                         \
+      if ((t = GetCurrentThread()) && !t->isUnwinding()) {                     \
+        uptr stack_top = t->stack_top();                                       \
+        uptr stack_bottom = t->stack_bottom();                                 \
+        ScopedUnwinding unwind_scope(t);                                       \
+        stack.Unwind(max_s, pc, bp, stack_top, stack_bottom, fast);            \
+      } else if (t == 0 && !fast) {                                            \
+        /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ \
+        stack.Unwind(max_s, pc, bp, 0, 0, fast);                               \
+        stack.top_frame_bp = bp;                                               \
+      }                                                                        \
+    }                                                                          \
   }
 #endif  // SANITIZER_WINDOWS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2290.1.patch
Type: text/x-patch
Size: 2544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131129/9f34d546/attachment.bin>


More information about the llvm-commits mailing list