[compiler-rt] r192956 - [asan] fix atexit stats

Kostya Serebryany kcc at google.com
Fri Oct 18 00:58:00 PDT 2013


Author: kcc
Date: Fri Oct 18 02:57:59 2013
New Revision: 192956

URL: http://llvm.org/viewvc/llvm-project?rev=192956&view=rev
Log:
[asan] fix atexit stats

Added:
    compiler-rt/trunk/lib/asan/lit_tests/TestCases/atexit_stats.cc
Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.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=192956&r1=192955&r2=192956&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Fri Oct 18 02:57:59 2013
@@ -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.

Modified: compiler-rt/trunk/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.cc?rev=192956&r1=192955&r2=192956&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/TestCases/assign_large_valloc_to_global.cc Fri Oct 18 02:57:59 2013
@@ -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 <stdlib.h>
-#else
 #include <malloc.h>
-#endif
 int *p = (int*)valloc(1 << 20);
 int main() { }

Added: compiler-rt/trunk/lib/asan/lit_tests/TestCases/atexit_stats.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/TestCases/atexit_stats.cc?rev=192956&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/TestCases/atexit_stats.cc (added)
+++ compiler-rt/trunk/lib/asan/lit_tests/TestCases/atexit_stats.cc Fri Oct 18 02:57:59 2013
@@ -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 <stdlib.h>
+#include <malloc.h>
+int *p1 = (int*)malloc(900);
+int *p2 = (int*)malloc(90000);
+int *p3 = (int*)malloc(9000000);
+int main() { }
+
+// CHECK: AddressSanitizer exit stats:





More information about the llvm-commits mailing list