aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/atexit2.cc
diff options
context:
space:
mode:
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 000000000000..6f74c5f9f6e5
--- /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
+