summaryrefslogtreecommitdiff
path: root/test/tsan/atexit2.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2014-09-17 00:12:50 +0000
committerDmitry Vyukov <dvyukov@google.com>2014-09-17 00:12:50 +0000
commit710b400e8cad9979b39db3649e21525e20dea0c7 (patch)
tree03364e9758b145afea4a0d259f63437db0c3f363 /test/tsan/atexit2.cc
parent6afe775d2ca25bb266f9c343861a1c33858f53db (diff)
tsan: fix crash when a program registers zillions of atexit callbacks
I don't remember that crash on mmap in internal allocator ever yielded anything useful, only crashes in rare wierd untested situations. One of the reasons for crash was to catch if tsan starts allocating clocks using mmap. Tsan does not allocate clocks using internal_alloc anymore. Solve it once and for all by allowing mmaps. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217929 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan/atexit2.cc')
-rw-r--r--test/tsan/atexit2.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/tsan/atexit2.cc b/test/tsan/atexit2.cc
new file mode 100644
index 000000000..6f74c5f9f
--- /dev/null
+++ b/test/tsan/atexit2.cc
@@ -0,0 +1,26 @@
+// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int n;
+const int N = 10000;
+
+static void atexit1() {
+ n++;
+}
+
+static void atexit0() {
+ fprintf(stderr, "run count: %d\n", n);
+}
+
+int main() {
+ atexit(atexit0);
+ for (int i = 0; i < N; i++)
+ atexit(atexit1);
+}
+
+// CHECK-NOT: FATAL: ThreadSanitizer
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK: run count: 10000
+