[compiler-rt] dd754cd - [compiler-rt][nsan] Update UnwindImpl (#107313)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 14:32:51 PDT 2024


Author: Alexander Shaposhnikov
Date: 2024-09-04T14:32:46-07:00
New Revision: dd754cd262222bcb489038ac791e4278d90697f0

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

LOG: [compiler-rt][nsan] Update UnwindImpl (#107313)

Implement __sanitizer::BufferedStackTrace::UnwindImpl following msan.

Added: 
    

Modified: 
    compiler-rt/lib/nsan/nsan.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index 4be9c673bd4e00..4679bcd589eb45 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -200,7 +200,14 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
                                                  bool request_fast,
                                                  u32 max_depth) {
   using namespace __nsan;
-  return Unwind(max_depth, pc, bp, context, 0, 0, false);
+  NsanThread *t = GetCurrentThread();
+  if (!t || !StackTrace::WillUseFastUnwind(request_fast))
+    return Unwind(max_depth, pc, bp, context, t ? t->stack_top() : 0,
+                  t ? t->stack_bottom() : 0, false);
+  if (StackTrace::WillUseFastUnwind(request_fast))
+    Unwind(max_depth, pc, bp, nullptr, t->stack_top(), t->stack_bottom(), true);
+  else
+    Unwind(max_depth, pc, 0, context, 0, 0, false);
 }
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_print_accumulated_stats() {


        


More information about the llvm-commits mailing list