[compiler-rt] r269917 - [sanitizer] Fix a crash when demangling Swift symbols, take 3

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Wed May 18 06:00:21 PDT 2016


Author: kuba.brecka
Date: Wed May 18 08:00:20 2016
New Revision: 269917

URL: http://llvm.org/viewvc/llvm-project?rev=269917&view=rev
Log:
[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.


Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=269917&r1=269916&r2=269917&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed May 18 08:00:20 2016
@@ -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");
 }

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=269917&r1=269916&r2=269917&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Wed May 18 08:00:20 2016
@@ -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) {




More information about the llvm-commits mailing list