[compiler-rt] r182571 - [lsan] Ensure lsan is initialized when interceptors are called.

Sergey Matveev earthdok at google.com
Thu May 23 03:24:45 PDT 2013


Author: smatveev
Date: Thu May 23 05:24:44 2013
New Revision: 182571

URL: http://llvm.org/viewvc/llvm-project?rev=182571&view=rev
Log:
[lsan] Ensure lsan is initialized when interceptors are called.

Also remove unnecessary ifdefs.

Modified:
    compiler-rt/trunk/lib/lsan/lsan.cc
    compiler-rt/trunk/lib/lsan/lsan_allocator.cc
    compiler-rt/trunk/lib/lsan/lsan_interceptors.cc

Modified: compiler-rt/trunk/lib/lsan/lsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.cc?rev=182571&r1=182570&r2=182571&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan.cc Thu May 23 05:24:44 2013
@@ -42,7 +42,6 @@ void Init() {
   SanitizerToolName = "LeakSanitizer";
   InitializeCommonFlags();
   InitializeAllocator();
-  InitCommonLsan();
   InitTlsSize();
   InitializeInterceptors();
   InitializeThreadRegistry();
@@ -57,10 +56,8 @@ void Init() {
     InitializeExternalSymbolizer(external_symbolizer);
   }
 
-#if CAN_SANITIZE_LEAKS
-  __lsan::InitCommonLsan();
-    Atexit(__lsan::DoLeakCheck);
-#endif
+  InitCommonLsan();
+  Atexit(DoLeakCheck);
 }
 
 }  // namespace __lsan

Modified: compiler-rt/trunk/lib/lsan/lsan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_allocator.cc?rev=182571&r1=182570&r2=182571&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_allocator.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_allocator.cc Thu May 23 05:24:44 2013
@@ -180,7 +180,6 @@ void ForEachChunk(Callable const &callba
   allocator.ForEachChunk(callback);
 }
 
-#if CAN_SANITIZE_LEAKS
 template void ForEachChunk<ProcessPlatformSpecificAllocationsCb>(
     ProcessPlatformSpecificAllocationsCb const &callback);
 template void ForEachChunk<PrintLeakedCb>(PrintLeakedCb const &callback);
@@ -189,5 +188,4 @@ template void ForEachChunk<MarkIndirectl
     MarkIndirectlyLeakedCb const &callback);
 template void ForEachChunk<ReportLeakedCb>(ReportLeakedCb const &callback);
 template void ForEachChunk<ClearTagCb>(ClearTagCb const &callback);
-#endif
 }  // namespace __lsan

Modified: compiler-rt/trunk/lib/lsan/lsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_interceptors.cc?rev=182571&r1=182570&r2=182571&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_interceptors.cc Thu May 23 05:24:44 2013
@@ -103,6 +103,7 @@ INTERCEPTOR(void*, valloc, uptr size) {
 }
 
 INTERCEPTOR(uptr, malloc_usable_size, void *ptr) {
+  Init();
   return GetMallocUsableSize(ptr);
 }
 
@@ -188,8 +189,9 @@ extern "C" void *__lsan_thread_start_fun
   return callback(param);
 }
 
-INTERCEPTOR(int, pthread_create,
-    void *th, void *attr, void *(*callback)(void*), void * param) {
+INTERCEPTOR(int, pthread_create, void *th, void *attr,
+            void *(*callback)(void *), void *param) {
+  Init();
   __sanitizer_pthread_attr_t myattr;
   if (attr == 0) {
     pthread_attr_init(&myattr);
@@ -216,6 +218,7 @@ INTERCEPTOR(int, pthread_create,
 }
 
 INTERCEPTOR(int, pthread_join, void *th, void **ret) {
+  Init();
   int tid = ThreadTid((uptr)th);
   int res = REAL(pthread_join)(th, ret);
   if (res == 0)





More information about the llvm-commits mailing list