From daac6a008380b2e3ecbb5bc3eefa1023cd5396c2 Mon Sep 17 00:00:00 2001 From: Kuba Brecka Date: Wed, 18 May 2016 13:00:20 +0000 Subject: [PATCH] [sanitizer] Fix a crash when demangling Swift symbols, take 3 The previous patch (r269291) was reverted (commented out) because the patch caused leaks that were detected by LSan and they broke some lit tests. The actual reason was that dlsym allocates an error string buffer in TLS, and some LSan lit tests are intentionally not scanning TLS for root pointers. This patch simply makes LSan ignore the allocation from dlsym, because it's not interesting anyway. llvm-svn: 269917 --- compiler-rt/lib/asan/asan_rtl.cc | 10 ++++++++-- compiler-rt/lib/tsan/rtl/tsan_rtl.cc | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 575c22755c72..b289b55c0c2f 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -553,8 +553,14 @@ static void AsanInitInternal() { InitializeSuppressions(); - // TODO(kuba) Fix Me. - // Symbolizer::LateInitialize(); + { +#if CAN_SANITIZE_LEAKS + // LateInitialize() calls dlsym, which can allocate an error string buffer + // in the TLS. Let's ignore the allocation to avoid reporting a leak. + __lsan::ScopedInterceptorDisabler disabler; +#endif + Symbolizer::LateInitialize(); + } VReport(1, "AddressSanitizer Init done\n"); } diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc index 03bda18c621b..629871ef8f7a 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc @@ -371,8 +371,7 @@ void Initialize(ThreadState *thr) { ctx->initialized = true; #ifndef SANITIZER_GO - // TODO(kuba) Fix Me. - // Symbolizer::LateInitialize(); + Symbolizer::LateInitialize(); #endif if (flags()->stop_on_start) {