From 063dfe32440f2b1ac03f51dca4b77cac96c95bb2 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 6 Mar 2013 16:11:58 +0000 Subject: [PATCH] [msan] Block reports from interceptors during _Unwind_Backtrace Summary: I'm hitting a big recursive report from: uninit on strlen -> __msan::PrintWarningWithOrigin() -> __msan::GetStackTrace() -> __sanitizer::StackTrace::SlowUnwindStack() -> _Unwind_Backtrace() -> ... libgcc calls -> uninit on strlen() -> ... repeats Reviewers: eugenis Differential Revision: http://llvm-reviews.chandlerc.com/D497 llvm-svn: 176555 --- compiler-rt/lib/msan/msan.cc | 5 ++++- compiler-rt/lib/msan/msan.h | 5 +++++ compiler-rt/lib/msan/msan_report.cc | 5 ----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler-rt/lib/msan/msan.cc b/compiler-rt/lib/msan/msan.cc index ba27234..cfa0741 100644 --- a/compiler-rt/lib/msan/msan.cc +++ b/compiler-rt/lib/msan/msan.cc @@ -153,8 +153,11 @@ static void GetCurrentStackBounds(uptr *stack_top, uptr *stack_bottom) { void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp, bool fast) { - if (!fast) + if (!fast) { + // Block reports from our interceptors during _Unwind_Backtrace. + SymbolizerScope sym_scope; return stack->SlowUnwindStack(pc, max_s); + } uptr stack_top, stack_bottom; GetCurrentStackBounds(&stack_top, &stack_bottom); diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h index 2150c83..fae1ad5 100644 --- a/compiler-rt/lib/msan/msan.h +++ b/compiler-rt/lib/msan/msan.h @@ -50,6 +50,11 @@ void EnterSymbolizer(); void ExitSymbolizer(); bool IsInSymbolizer(); +struct SymbolizerScope { + SymbolizerScope() { EnterSymbolizer(); } + ~SymbolizerScope() { ExitSymbolizer(); } +}; + void MsanDie(); void PrintWarning(uptr pc, uptr bp); void PrintWarningWithOrigin(uptr pc, uptr bp, u32 origin); diff --git a/compiler-rt/lib/msan/msan_report.cc b/compiler-rt/lib/msan/msan_report.cc index 16b13f6..df6990f 100644 --- a/compiler-rt/lib/msan/msan_report.cc +++ b/compiler-rt/lib/msan/msan_report.cc @@ -44,11 +44,6 @@ class Decorator: private __sanitizer::AnsiColorDecorator { const char *End() { return Default(); } }; -struct SymbolizerScope { - SymbolizerScope() { EnterSymbolizer(); } - ~SymbolizerScope() { ExitSymbolizer(); } -}; - static void PrintStack(const uptr *trace, uptr size) { SymbolizerScope sym_scope; StackTrace::PrintStack(trace, size, true, flags()->strip_path_prefix, 0); -- 2.7.4