[PATCH] D27866: [tsan] Pass BP and stack bounds to Unwind() to get full stack traces on failed CHECKs

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 15:30:53 PST 2016

kubabrecka created this revision.
kubabrecka added a reviewer: dvyukov.
kubabrecka added subscribers: llvm-commits, zaks.anna.
kubabrecka set the repository for this revision to rL LLVM.
kubabrecka added a project: Sanitizers.

At least on Darwin, the fast unwinder called from TsanCheckFailed completely fails to unwind anything, because we don't give it a valid bp, stack_top and stack_bottom.  Let's fix that.




Index: lib/tsan/rtl/tsan_rtl_report.cc
--- lib/tsan/rtl/tsan_rtl_report.cc
+++ lib/tsan/rtl/tsan_rtl_report.cc
@@ -697,7 +697,10 @@
   BufferedStackTrace *ptrace =
       new(internal_alloc(MBlockStackTrace, sizeof(BufferedStackTrace)))
-  ptrace->Unwind(kStackTraceMax, pc, 0, 0, 0, 0, false);
+  uptr stack_bottom = cur_thread()->stk_addr;
+  uptr stack_top = stack_bottom + cur_thread()->stk_size;
+  uptr bp = GET_CURRENT_FRAME();
+  ptrace->Unwind(kStackTraceMax, pc, bp, 0, stack_top, stack_bottom, false);
   for (uptr i = 0; i < ptrace->size / 2; i++) {
     uptr tmp = ptrace->trace_buffer[i];
     ptrace->trace_buffer[i] = ptrace->trace_buffer[ptrace->size - i - 1];

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27866.81805.patch
Type: text/x-patch
Size: 779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161216/e3d9f258/attachment.bin>

More information about the llvm-commits mailing list