[compiler-rt] 3827eff - [Asan][Windows] Fix asan stack traces on Windows.

Amy Huang via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 13:14:31 PDT 2020


Author: Amy Huang
Date: 2020-10-23T13:14:14-07:00
New Revision: 3827effe3ab541a3357c417c676939826fc5b4ac

URL: https://github.com/llvm/llvm-project/commit/3827effe3ab541a3357c417c676939826fc5b4ac
DIFF: https://github.com/llvm/llvm-project/commit/3827effe3ab541a3357c417c676939826fc5b4ac.diff

LOG: [Asan][Windows] Fix asan stack traces on Windows.

While implementing inline stack traces on Windows I noticed that the stack
traces in many asan tests included an inlined frame that shouldn't be there.

Currently we get the PC and then do a stack unwind and use the PC to
find the beginning of the stack trace.
In the failing tests the first thing in the stack trace is inside an inline
call site that shouldn't be in the stack trace, so replace it with the PC.

Differential Revision: https://reviews.llvm.org/D89996

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp
index 8e06940685dc..e2edf428004e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp
@@ -37,6 +37,10 @@ void BufferedStackTrace::UnwindSlow(uptr pc, u32 max_depth) {
   // Skip the RTL frames by searching for the PC in the stacktrace.
   uptr pc_location = LocatePcInTrace(pc);
   PopStackFrames(pc_location);
+
+  // Replace the first frame with the PC because the frame in the
+  // stacktrace might be incorrect.
+  trace_buffer[0] = pc;
 }
 
 void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {


        


More information about the llvm-commits mailing list