From 710b400e8cad9979b39db3649e21525e20dea0c7 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 17 Sep 2014 00:12:50 +0000 Subject: 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 --- test/tsan/atexit2.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/tsan/atexit2.cc (limited to 'test/tsan/atexit2.cc') 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 +#include + +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 + -- cgit v1.2.3