diff options
| author | Sergey Matveev <earthdok@google.com> | 2013-05-23 10:24:44 +0000 |
|---|---|---|
| committer | Sergey Matveev <earthdok@google.com> | 2013-05-23 10:24:44 +0000 |
| commit | bb12f840b50a5759cf9eb30b96c94f5383943e1d (patch) | |
| tree | 333fba8b1f7a71067306b8782cf10c7753c762cd | |
| parent | e5777d25d693a90442d1fe41cece50861d925ee5 (diff) | |
| download | bcm5719-llvm-bb12f840b50a5759cf9eb30b96c94f5383943e1d.tar.gz bcm5719-llvm-bb12f840b50a5759cf9eb30b96c94f5383943e1d.zip | |
[lsan] Ensure lsan is initialized when interceptors are called.
Also remove unnecessary ifdefs.
llvm-svn: 182571
| -rw-r--r-- | compiler-rt/lib/lsan/lsan.cc | 7 | ||||
| -rw-r--r-- | compiler-rt/lib/lsan/lsan_allocator.cc | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/lsan/lsan_interceptors.cc | 7 |
3 files changed, 7 insertions, 9 deletions
diff --git a/compiler-rt/lib/lsan/lsan.cc b/compiler-rt/lib/lsan/lsan.cc index 278492b5265..9b83b411f84 100644 --- a/compiler-rt/lib/lsan/lsan.cc +++ b/compiler-rt/lib/lsan/lsan.cc @@ -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 diff --git a/compiler-rt/lib/lsan/lsan_allocator.cc b/compiler-rt/lib/lsan/lsan_allocator.cc index cde18c965c9..9bf27b106ba 100644 --- a/compiler-rt/lib/lsan/lsan_allocator.cc +++ b/compiler-rt/lib/lsan/lsan_allocator.cc @@ -180,7 +180,6 @@ void ForEachChunk(Callable const &callback) { 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<MarkIndirectlyLeakedCb>( MarkIndirectlyLeakedCb const &callback); template void ForEachChunk<ReportLeakedCb>(ReportLeakedCb const &callback); template void ForEachChunk<ClearTagCb>(ClearTagCb const &callback); -#endif } // namespace __lsan diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cc b/compiler-rt/lib/lsan/lsan_interceptors.cc index 90536f5b5b7..b2eb6e31022 100644 --- a/compiler-rt/lib/lsan/lsan_interceptors.cc +++ b/compiler-rt/lib/lsan/lsan_interceptors.cc @@ -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_func(void *arg) { 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) |

