[compiler-rt] r182399 - [lsan] Invoke leak detection with atexit().
Sergey Matveev
earthdok at google.com
Tue May 21 10:56:46 PDT 2013
Author: smatveev
Date: Tue May 21 12:56:45 2013
New Revision: 182399
URL: http://llvm.org/viewvc/llvm-project?rev=182399&view=rev
Log:
[lsan] Invoke leak detection with atexit().
Keeps it consistent between ASan and LSan.
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/lsan/lsan.cc
compiler-rt/trunk/lib/lsan/lsan_allocator.cc
compiler-rt/trunk/lib/lsan/tests/lsan_testlib.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=182399&r1=182398&r2=182399&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue May 21 12:56:45 2013
@@ -465,12 +465,6 @@ void __asan_init() {
Atexit(asan_atexit);
}
-#if CAN_SANITIZE_LEAKS
- if (flags()->detect_leaks) {
- Atexit(__lsan::DoLeakCheck);
- }
-#endif
-
// interceptors
InitializeAsanInterceptors();
@@ -550,12 +544,15 @@ void __asan_init() {
main_thread->ThreadStart(internal_getpid());
force_interface_symbols(); // no-op.
+ InitializeAllocator();
+
#if CAN_SANITIZE_LEAKS
__lsan::InitCommonLsan();
+ if (flags()->detect_leaks) {
+ Atexit(__lsan::DoLeakCheck);
+ }
#endif
- InitializeAllocator();
-
if (flags()->verbosity) {
Report("AddressSanitizer Init done\n");
}
Modified: compiler-rt/trunk/lib/lsan/lsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.cc?rev=182399&r1=182398&r2=182399&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan.cc Tue May 21 12:56:45 2013
@@ -56,6 +56,11 @@ void Init() {
external_symbolizer[0]) {
InitializeExternalSymbolizer(external_symbolizer);
}
+
+#if CAN_SANITIZE_LEAKS
+ __lsan::InitCommonLsan();
+ Atexit(__lsan::DoLeakCheck);
+#endif
}
} // 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=182399&r1=182398&r2=182399&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_allocator.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_allocator.cc Tue May 21 12:56:45 2013
@@ -180,6 +180,7 @@ 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);
@@ -188,5 +189,5 @@ 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/tests/lsan_testlib.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/tests/lsan_testlib.cc?rev=182399&r1=182398&r2=182399&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/lsan_testlib.cc (original)
+++ compiler-rt/trunk/lib/lsan/tests/lsan_testlib.cc Tue May 21 12:56:45 2013
@@ -17,15 +17,9 @@ clang++ ../sanitizer_common/sanitizer_*.
-o lsan.so
LD_PRELOAD=./lsan.so /your/app
*/
-#include "lsan_common.h"
#include "lsan.h"
__attribute__((constructor))
void constructor() {
__lsan::Init();
}
-
-__attribute__((destructor))
-void destructor() {
- __lsan::DoLeakCheck();
-}
More information about the llvm-commits
mailing list