diff options
author | Kuba Brecka <kuba.brecka@gmail.com> | 2016-03-24 11:50:21 +0000 |
---|---|---|
committer | Kuba Brecka <kuba.brecka@gmail.com> | 2016-03-24 11:50:21 +0000 |
commit | fae6b41b0c7c561e2e1aa659dddcb4b9a9826fbd (patch) | |
tree | 5f53300a34d58a1d316f94416d1501290d370fe0 /test | |
parent | 876379e4c2d7bf44a78dc3e596e1f5e80971fd2e (diff) |
[tsan] Use direct syscalls for internal_mmap and internal_munmap on OS X
On OS X, internal_mmap just uses mmap, which can invoke callbacks into libmalloc (e.g. when MallocStackLogging is enabled). This can subsequently call other intercepted functions, and this breaks our Darwin-specific ThreadState initialization. Let's use direct syscalls in internal_mmap and internal_munmap. Added a testcase.
Differential Revision: http://reviews.llvm.org/D18431
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264259 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/tsan/Darwin/malloc-stack-logging.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/tsan/Darwin/malloc-stack-logging.cc b/test/tsan/Darwin/malloc-stack-logging.cc new file mode 100644 index 000000000..447fcd1a9 --- /dev/null +++ b/test/tsan/Darwin/malloc-stack-logging.cc @@ -0,0 +1,19 @@ +// RUN: %clangxx_tsan -O1 %s -o %t +// RUN: MallocStackLogging=1 %run %t 2>&1 | FileCheck %s +#include <pthread.h> +#include <stdlib.h> +#include <stdio.h> + +void *foo(void *p) { + return NULL; +} + +int main() { + pthread_t t; + pthread_create(&t, NULL, foo, NULL); + pthread_join(t, NULL); + fprintf(stderr, "Done.\n"); + return 0; +} + +// CHECK: Done. |