From 17f5705d3c0e87a3713f28dfcc18196a9075a92b Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 21 May 2013 15:35:34 +0000 Subject: [PATCH] [asan] Do not invoke LSan hooks unless CAN_SANITIZE_LEAKS. llvm-svn: 182389 --- compiler-rt/lib/asan/asan_rtl.cc | 4 ++++ compiler-rt/lib/lsan/lsan_common.cc | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index a30dc1d207e3..595b722e74fc 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -465,9 +465,11 @@ void __asan_init() { Atexit(asan_atexit); } +#if CAN_SANITIZE_LEAKS if (flags()->detect_leaks) { Atexit(__lsan::DoLeakCheck); } +#endif // interceptors InitializeAsanInterceptors(); @@ -548,7 +550,9 @@ void __asan_init() { main_thread->ThreadStart(internal_getpid()); force_interface_symbols(); // no-op. +#if CAN_SANITIZE_LEAKS __lsan::InitCommonLsan(); +#endif InitializeAllocator(); diff --git a/compiler-rt/lib/lsan/lsan_common.cc b/compiler-rt/lib/lsan/lsan_common.cc index 18d913dfbc5f..480b6c4eaf2c 100644 --- a/compiler-rt/lib/lsan/lsan_common.cc +++ b/compiler-rt/lib/lsan/lsan_common.cc @@ -20,8 +20,9 @@ #include "sanitizer_common/sanitizer_stacktrace.h" #include "sanitizer_common/sanitizer_stoptheworld.h" -namespace __lsan { #if CAN_SANITIZE_LEAKS +namespace __lsan { + Flags lsan_flags; static void InitializeFlags() { @@ -381,8 +382,6 @@ void LeakReport::PrintLargest(uptr max_leaks) { remaining > 1 ? "s" : ""); } } -#else // CAN_SANITIZE_LEAKS -void InitCommonLsan() {} -void DoLeakCheck() {} -#endif // CAN_SANITIZE_LEAKS + } // namespace __lsan +#endif // CAN_SANITIZE_LEAKS