[compiler-rt] [compiler-rt][nsan] Update UnwindImpl (PR #107313)
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 14:29:38 PDT 2024
https://github.com/alexander-shaposhnikov updated https://github.com/llvm/llvm-project/pull/107313
>From b232bdb1aa970c2ee4fba05ff5859c1af1bae18d Mon Sep 17 00:00:00 2001
From: Alexander Shaposhnikov <ashaposhnikov at google.com>
Date: Wed, 4 Sep 2024 21:13:47 +0000
Subject: [PATCH] [compiler-rt][nsan] Update
__sanitizer::BufferedStackTrace::UnwindImpl following msan's example
---
compiler-rt/lib/nsan/nsan.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index 4be9c673bd4e00..c9a24b36c9dd47 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -199,8 +199,15 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
void *context,
bool request_fast,
u32 max_depth) {
- using namespace __nsan;
- return Unwind(max_depth, pc, bp, context, 0, 0, false);
+ using namespace __msan;
+ 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