diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h index f1f29e9f32e..295d79f7dd7 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h @@ -104,6 +104,12 @@ struct BufferedStackTrace : public StackTrace { // The bp may refer to the current frame or to the caller's frame. void Unwind(uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth = kStackTraceMax) { + static THREADLOCAL bool is_already_here; + + if (is_already_here == true) { + return; + } + is_already_here = true; top_frame_bp = (max_depth > 0) ? bp : 0; // Small max_depth optimization if (max_depth <= 1) { @@ -113,6 +119,7 @@ struct BufferedStackTrace : public StackTrace { return; } UnwindImpl(pc, bp, context, request_fast, max_depth); + is_already_here = false; } void Unwind(u32 max_depth, uptr pc, uptr bp, void *context, uptr stack_top,