From 4bf67d99f4a09e45347cb02ea50c8d1fb50bb00a Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Fri, 18 Oct 2013 07:57:59 +0000 Subject: [PATCH] [asan] fix atexit stats llvm-svn: 192956 --- compiler-rt/lib/asan/asan_rtl.cc | 9 ++++----- .../TestCases/assign_large_valloc_to_global.cc | 3 --- .../lib/asan/lit_tests/TestCases/atexit_stats.cc | 11 +++++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 compiler-rt/lib/asan/lit_tests/TestCases/atexit_stats.cc diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index ce7278f027a5..2b4114a057ca 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -474,11 +474,6 @@ void __asan_init() { // Setup internal allocator callback. SetLowLevelAllocateCallback(OnLowLevelAllocate); - if (flags()->atexit) { - Atexit(asan_atexit); - } - - // interceptors InitializeAsanInterceptors(); ReplaceSystemMalloc(); @@ -551,6 +546,10 @@ void __asan_init() { asan_inited = 1; asan_init_is_running = false; + if (flags()->atexit) + Atexit(asan_atexit); + + // interceptors InitTlsSize(); // Create main thread. diff --git a/compiler-rt/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.cc b/compiler-rt/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.cc index 87a65984cdaf..e5b2e661eca6 100644 --- a/compiler-rt/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.cc +++ b/compiler-rt/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.cc @@ -1,9 +1,6 @@ // Make sure we don't report a leak nor hang. // RUN: %clangxx_asan -O3 %s -o %t && %t -#if defined(__APPLE__) #include -#else #include -#endif int *p = (int*)valloc(1 << 20); int main() { } diff --git a/compiler-rt/lib/asan/lit_tests/TestCases/atexit_stats.cc b/compiler-rt/lib/asan/lit_tests/TestCases/atexit_stats.cc new file mode 100644 index 000000000000..10b4fac41785 --- /dev/null +++ b/compiler-rt/lib/asan/lit_tests/TestCases/atexit_stats.cc @@ -0,0 +1,11 @@ +// Make sure we report atexit stats. +// RUN: %clangxx_asan -O3 %s -o %t +// RUN: ASAN_OPTIONS=atexit=1:print_stats=1 %t 2>&1 | FileCheck %s +#include +#include +int *p1 = (int*)malloc(900); +int *p2 = (int*)malloc(90000); +int *p3 = (int*)malloc(9000000); +int main() { } + +// CHECK: AddressSanitizer exit stats: