[compiler-rt] r355171 - Revert "[NFC][Sanitizer] Add new BufferedStackTrace::Unwind API"
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 28 19:35:05 PST 2019
Author: yln
Date: Thu Feb 28 19:35:05 2019
New Revision: 355171
URL: http://llvm.org/viewvc/llvm-project?rev=355171&view=rev
Log:
Revert "[NFC][Sanitizer] Add new BufferedStackTrace::Unwind API"
This reverts commit 6112f37e758ebf2405955e091a745f5003c1f562.
Modified:
compiler-rt/trunk/lib/asan/asan_errors.cc
compiler-rt/trunk/lib/asan/asan_stack.h
compiler-rt/trunk/lib/hwasan/hwasan.h
compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp
compiler-rt/trunk/lib/lsan/lsan.cc
compiler-rt/trunk/lib/lsan/lsan.h
compiler-rt/trunk/lib/msan/msan.cc
compiler-rt/trunk/lib/msan/msan.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
compiler-rt/trunk/lib/ubsan/ubsan_diag_standalone.cc
Modified: compiler-rt/trunk/lib/asan/asan_errors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_errors.cc?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_errors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_errors.cc Thu Feb 28 19:35:05 2019
@@ -35,7 +35,7 @@ static void OnStackUnwind(const SignalCo
// corresponding code in the sanitizer_common and we use this callback to
// print it.
static_cast<const ScarinessScoreBase *>(callback_context)->Print();
- stack->Unwind(sig.pc, sig.bp, sig.context, fast);
+ GetStackTrace(stack, kStackTraceMax, sig.pc, sig.bp, sig.context, fast);
}
void ErrorDeadlySignal::Print() {
Modified: compiler-rt/trunk/lib/asan/asan_stack.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.h?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.h (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.h Thu Feb 28 19:35:05 2019
@@ -42,19 +42,19 @@ u32 GetMallocContextSize();
if (max_size > 1) stack.trace_buffer[1] = GET_CALLER_PC(); \
} \
} else { \
- stack.Unwind(StackTrace::GetCurrentPc(), \
- GET_CURRENT_FRAME(), nullptr, fast, max_size); \
+ GetStackTrace(&stack, max_size, StackTrace::GetCurrentPc(), \
+ GET_CURRENT_FRAME(), 0, fast); \
}
#define GET_STACK_TRACE_FATAL(pc, bp) \
BufferedStackTrace stack; \
- stack.Unwind(pc, bp, nullptr, \
- common_flags()->fast_unwind_on_fatal)
+ GetStackTrace(&stack, kStackTraceMax, pc, bp, 0, \
+ common_flags()->fast_unwind_on_fatal)
#define GET_STACK_TRACE_SIGNAL(sig) \
BufferedStackTrace stack; \
- stack.Unwind((sig).pc, (sig).bp, (sig).context, \
- common_flags()->fast_unwind_on_fatal)
+ GetStackTrace(&stack, kStackTraceMax, (sig).pc, (sig).bp, (sig).context, \
+ common_flags()->fast_unwind_on_fatal)
#define GET_STACK_TRACE_FATAL_HERE \
GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal)
Modified: compiler-rt/trunk/lib/hwasan/hwasan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan.h?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan.h (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan.h Thu Feb 28 19:35:05 2019
@@ -112,15 +112,16 @@ const int STACK_TRACE_TAG_POISON = Stack
#define GET_MALLOC_STACK_TRACE \
BufferedStackTrace stack; \
- if (hwasan_inited) \
- stack.Unwind(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), \
- nullptr, common_flags()->fast_unwind_on_malloc, \
- common_flags()->malloc_context_size)
+ if (hwasan_inited) \
+ GetStackTrace(&stack, common_flags()->malloc_context_size, \
+ StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), nullptr, \
+ common_flags()->fast_unwind_on_malloc)
#define GET_FATAL_STACK_TRACE_PC_BP(pc, bp) \
BufferedStackTrace stack; \
- if (hwasan_inited) \
- stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal)
+ if (hwasan_inited) \
+ GetStackTrace(&stack, kStackTraceMax, pc, bp, nullptr, \
+ common_flags()->fast_unwind_on_fatal)
#define GET_FATAL_STACK_TRACE_HERE \
GET_FATAL_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME())
Modified: compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp Thu Feb 28 19:35:05 2019
@@ -378,7 +378,8 @@ static void HandleTagMismatch(AccessInfo
InternalMmapVector<BufferedStackTrace> stack_buffer(1);
BufferedStackTrace *stack = stack_buffer.data();
stack->Reset();
- stack->Unwind(pc, frame, uc, common_flags()->fast_unwind_on_fatal);
+ GetStackTrace(stack, kStackTraceMax, pc, frame, uc,
+ common_flags()->fast_unwind_on_fatal);
bool fatal = flags()->halt_on_error || !ai.recover;
ReportTagMismatch(stack, ai.addr, ai.size, ai.is_store, fatal);
@@ -416,8 +417,8 @@ extern "C" SANITIZER_INTERFACE_ATTRIBUTE
static void OnStackUnwind(const SignalContext &sig, const void *,
BufferedStackTrace *stack) {
- stack->Unwind(StackTrace::GetNextInstructionPc(sig.pc), sig.bp, sig.context,
- common_flags()->fast_unwind_on_fatal);
+ GetStackTrace(stack, kStackTraceMax, StackTrace::GetNextInstructionPc(sig.pc),
+ sig.bp, sig.context, common_flags()->fast_unwind_on_fatal);
}
void HwasanOnDeadlySignal(int signo, void *info, void *context) {
Modified: compiler-rt/trunk/lib/lsan/lsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.cc?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan.cc Thu Feb 28 19:35:05 2019
@@ -89,7 +89,7 @@ static void InitializeFlags() {
static void OnStackUnwind(const SignalContext &sig, const void *,
BufferedStackTrace *stack) {
- stack->Unwind(sig.pc, sig.bp, sig.context,
+ GetStackTrace(stack, kStackTraceMax, sig.pc, sig.bp, sig.context,
common_flags()->fast_unwind_on_fatal);
}
Modified: compiler-rt/trunk/lib/lsan/lsan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.h?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan.h (original)
+++ compiler-rt/trunk/lib/lsan/lsan.h Thu Feb 28 19:35:05 2019
@@ -17,8 +17,8 @@
#define GET_STACK_TRACE(max_size, fast) \
__sanitizer::BufferedStackTrace stack; \
- stack.Unwind(StackTrace::GetCurrentPc(), \
- GET_CURRENT_FRAME(), nullptr, fast, max_size);
+ GetStackTrace(&stack, max_size, StackTrace::GetCurrentPc(), \
+ GET_CURRENT_FRAME(), nullptr, fast);
#define GET_STACK_TRACE_FATAL \
GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal)
Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Thu Feb 28 19:35:05 2019
@@ -382,7 +382,7 @@ void __msan_warning_noreturn() {
static void OnStackUnwind(const SignalContext &sig, const void *,
BufferedStackTrace *stack) {
- stack->Unwind(sig.pc, sig.bp, sig.context,
+ GetStackTrace(stack, kStackTraceMax, sig.pc, sig.bp, sig.context,
common_flags()->fast_unwind_on_fatal);
}
Modified: compiler-rt/trunk/lib/msan/msan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.h?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.h (original)
+++ compiler-rt/trunk/lib/msan/msan.h Thu Feb 28 19:35:05 2019
@@ -325,21 +325,23 @@ const int STACK_TRACE_TAG_POISON = Stack
#define GET_MALLOC_STACK_TRACE \
BufferedStackTrace stack; \
if (__msan_get_track_origins() && msan_inited) \
- stack.Unwind(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), \
- nullptr, common_flags()->fast_unwind_on_malloc, \
- common_flags()->malloc_context_size)
+ GetStackTrace(&stack, common_flags()->malloc_context_size, \
+ StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), nullptr, \
+ common_flags()->fast_unwind_on_malloc)
// For platforms which support slow unwinder only, we restrict the store context
// size to 1, basically only storing the current pc. We do this because the slow
// unwinder which is based on libunwind is not async signal safe and causes
// random freezes in forking applications as well as in signal handlers.
-#define GET_STORE_STACK_TRACE_PC_BP(pc, bp) \
- BufferedStackTrace stack; \
- if (__msan_get_track_origins() > 1 && msan_inited) { \
- int size = flags()->store_context_size; \
- if (!SANITIZER_CAN_FAST_UNWIND) \
- size = Min(size, 1); \
- stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_malloc, size);\
+#define GET_STORE_STACK_TRACE_PC_BP(pc, bp) \
+ BufferedStackTrace stack; \
+ if (__msan_get_track_origins() > 1 && msan_inited) { \
+ if (!SANITIZER_CAN_FAST_UNWIND) \
+ GetStackTrace(&stack, Min(1, flags()->store_context_size), pc, bp, \
+ nullptr, false); \
+ else \
+ GetStackTrace(&stack, flags()->store_context_size, pc, bp, nullptr, \
+ common_flags()->fast_unwind_on_malloc); \
}
#define GET_STORE_STACK_TRACE \
@@ -348,7 +350,8 @@ const int STACK_TRACE_TAG_POISON = Stack
#define GET_FATAL_STACK_TRACE_PC_BP(pc, bp) \
BufferedStackTrace stack; \
if (msan_inited) \
- stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal)
+ GetStackTrace(&stack, kStackTraceMax, pc, bp, nullptr, \
+ common_flags()->fast_unwind_on_fatal)
#define GET_FATAL_STACK_TRACE_HERE \
GET_FATAL_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME())
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h Thu Feb 28 19:35:05 2019
@@ -16,13 +16,6 @@
namespace __sanitizer {
-struct BufferedStackTrace;
-// Get the stack trace with the given pc and bp.
-// The pc will be in the position 0 of the resulting stack trace.
-// The bp may refer to the current frame or to the caller's frame.
-void GetStackTrace(BufferedStackTrace *stack, uptr max_depth, uptr pc, uptr bp,
- void *context, bool request_fast_unwind);
-
static const u32 kStackTraceMax = 256;
#if defined(__sparc__) || (SANITIZER_LINUX && defined(__mips__))
@@ -103,20 +96,6 @@ struct BufferedStackTrace : public Stack
BufferedStackTrace() : StackTrace(trace_buffer, 0), top_frame_bp(0) {}
void Init(const uptr *pcs, uptr cnt, uptr extra_top_pc = 0);
-
- void Unwind(uptr pc, uptr bp, void *context, bool request_fast,
- u32 max_depth = kStackTraceMax) {
- top_frame_bp = (max_depth > 0) ? bp : 0;
- // Small max_depth optimization
- if (max_depth <= 1) {
- if (max_depth == 1)
- trace_buffer[0] = pc;
- size = max_depth;
- return;
- }
- GetStackTrace(this, max_depth, pc, bp, context, request_fast);
- }
-
void Unwind(u32 max_depth, uptr pc, uptr bp, void *context, uptr stack_top,
uptr stack_bottom, bool request_fast_unwind);
@@ -142,27 +121,31 @@ static inline bool IsValidFrame(uptr fra
return frame > stack_bottom && frame < stack_top - 2 * sizeof (uhwptr);
}
+// Get the stack trace with the given pc and bp.
+// The pc will be in the position 0 of the resulting stack trace.
+// The bp may refer to the current frame or to the caller's frame.
+void GetStackTrace(BufferedStackTrace *stack, uptr max_depth, uptr pc, uptr bp,
+ void *context, bool request_fast_unwind);
+
} // namespace __sanitizer
// Use this macro if you want to print stack trace with the caller
// of the current function in the top frame.
-#define GET_CALLER_PC_BP \
- uptr bp = GET_CURRENT_FRAME(); \
- uptr pc = GET_CALLER_PC();
-
#define GET_CALLER_PC_BP_SP \
- GET_CALLER_PC_BP; \
+ uptr bp = GET_CURRENT_FRAME(); \
+ uptr pc = GET_CALLER_PC(); \
uptr local_stack; \
uptr sp = (uptr)&local_stack
-// Use this macro if you want to print stack trace with the current
-// function in the top frame.
-#define GET_CURRENT_PC_BP \
+#define GET_CALLER_PC_BP \
uptr bp = GET_CURRENT_FRAME(); \
- uptr pc = StackTrace::GetCurrentPc()
+ uptr pc = GET_CALLER_PC();
+// Use this macro if you want to print stack trace with the current
+// function in the top frame.
#define GET_CURRENT_PC_BP_SP \
- GET_CURRENT_PC_BP; \
+ uptr bp = GET_CURRENT_FRAME(); \
+ uptr pc = StackTrace::GetCurrentPc(); \
uptr local_stack; \
uptr sp = (uptr)&local_stack
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_report.cc?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_report.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_report.cc Thu Feb 28 19:35:05 2019
@@ -98,9 +98,16 @@ void ReportMmapWriteExec(int prot) {
InternalMmapVector<BufferedStackTrace> stack_buffer(1);
BufferedStackTrace *stack = stack_buffer.data();
stack->Reset();
-
- GET_CALLER_PC_BP;
- stack->Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal);
+ uptr top = 0;
+ uptr bottom = 0;
+ GET_CALLER_PC_BP_SP;
+ (void)sp;
+ bool fast = common_flags()->fast_unwind_on_fatal;
+ if (StackTrace::WillUseFastUnwind(fast)) {
+ GetThreadStackTopAndBottom(false, &top, &bottom);
+ stack->Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom, true);
+ } else
+ stack->Unwind(kStackTraceMax, pc, 0, nullptr, 0, 0, false);
Printf("%s", d.Warning());
Report("WARNING: %s: writable-executable page usage\n", SanitizerToolName);
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Thu Feb 28 19:35:05 2019
@@ -328,8 +328,14 @@ static void CheckShadowMapping() {
#if !SANITIZER_GO
static void OnStackUnwind(const SignalContext &sig, const void *,
BufferedStackTrace *stack) {
- stack->Unwind(sig.pc, sig.bp, sig.context,
- common_flags()->fast_unwind_on_fatal);
+ uptr top = 0;
+ uptr bottom = 0;
+ bool fast = common_flags()->fast_unwind_on_fatal;
+ if (StackTrace::WillUseFastUnwind(fast)) {
+ GetThreadStackTopAndBottom(false, &top, &bottom);
+ stack->Unwind(kStackTraceMax, sig.pc, sig.bp, nullptr, top, bottom, true);
+ } else
+ stack->Unwind(kStackTraceMax, sig.pc, 0, sig.context, 0, 0, false);
}
static void TsanOnDeadlySignal(int signo, void *siginfo, void *context) {
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Thu Feb 28 19:35:05 2019
@@ -729,12 +729,18 @@ void PrintCurrentStack(ThreadState *thr,
ALWAYS_INLINE
void PrintCurrentStackSlow(uptr pc) {
#if !SANITIZER_GO
- uptr bp = GET_CURRENT_FRAME();
+ uptr bp = 0;
+ uptr top = 0;
+ uptr bottom = 0;
BufferedStackTrace *ptrace =
new(internal_alloc(MBlockStackTrace, sizeof(BufferedStackTrace)))
BufferedStackTrace();
- ptrace->Unwind(pc, bp, nullptr, false);
-
+ if (__sanitizer::StackTrace::WillUseFastUnwind(false)) {
+ bp = GET_CURRENT_FRAME();
+ __sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom);
+ ptrace->Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom, true);
+ } else
+ ptrace->Unwind(kStackTraceMax, pc, 0, nullptr, 0, 0, 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];
Modified: compiler-rt/trunk/lib/ubsan/ubsan_diag_standalone.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_diag_standalone.cc?rev=355171&r1=355170&r2=355171&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_diag_standalone.cc (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_diag_standalone.cc Thu Feb 28 19:35:05 2019
@@ -16,23 +16,21 @@
using namespace __ubsan;
-void __sanitizer::GetStackTrace(BufferedStackTrace *stack, uptr max_depth,
- uptr pc, uptr bp, void *context, bool fast) {
- uptr top = 0;
- uptr bottom = 0;
- if (StackTrace::WillUseFastUnwind(fast)) {
- GetThreadStackTopAndBottom(false, &top, &bottom);
- stack->Unwind(max_depth, pc, bp, nullptr, top, bottom, true);
- } else
- stack->Unwind(max_depth, pc, bp, context, 0, 0, false);
-}
-
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE
void __sanitizer_print_stack_trace() {
- GET_CURRENT_PC_BP;
+ uptr top = 0;
+ uptr bottom = 0;
+ bool request_fast_unwind = common_flags()->fast_unwind_on_fatal;
+ GET_CURRENT_PC_BP_SP;
+ (void)sp;
BufferedStackTrace stack;
- stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal);
+ if (__sanitizer::StackTrace::WillUseFastUnwind(request_fast_unwind)) {
+ __sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom);
+ stack.Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom, true);
+ } else {
+ stack.Unwind(kStackTraceMax, pc, 0, nullptr, 0, 0, false);
+ }
stack.Print();
}
} // extern "C"
More information about the llvm-commits
mailing list