diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2016-05-10 11:19:50 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2016-05-10 11:19:50 +0000 |
commit | 1b79d38cc4520464c5e876ffbef81f4e0cdc8720 (patch) | |
tree | 0cd2ed99da45b83ec152f34547df16c3eae363dd /test | |
parent | f938294524df0b8a39a220e7e77ace25edbb9bb8 (diff) |
tsan: fix another crash due to processors
Another stack where we try to free sync objects,
but don't have a processors is:
// ResetRange
// __interceptor_munmap
// __deallocate_stack
// start_thread
// clone
Again, it is a latent bug that lead to memory leaks.
Also, increase amount of memory we scan in MetaMap::ResetRange.
Without that the test does not fail, as we fail to free
the sync objects on stack.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269041 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/tsan/lots_of_threads.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/tsan/lots_of_threads.c b/test/tsan/lots_of_threads.c new file mode 100644 index 000000000..eef9b1cb0 --- /dev/null +++ b/test/tsan/lots_of_threads.c @@ -0,0 +1,30 @@ +// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s +#include "test.h" + +void *thr(void *arg) { + // Create a sync object on stack, so there is something to free on thread end. + volatile int x; + __atomic_fetch_add(&x, 1, __ATOMIC_SEQ_CST); + barrier_wait(&barrier); + return 0; +} + +int main() { + const int kThreads = 10; + barrier_init(&barrier, kThreads + 1); + pthread_t t[kThreads]; + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setstacksize(&attr, 16 << 20); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + for (int i = 0; i < kThreads; i++) + pthread_create(&t[i], &attr, thr, 0); + pthread_attr_destroy(&attr); + barrier_wait(&barrier); + sleep(1); + fprintf(stderr, "DONE\n"); + return 0; +} + +// CHECK: DONE + |