summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2014-05-13 16:17:54 +0000
committerAlexander Potapenko <glider@google.com>2014-05-13 16:17:54 +0000
commit8563d6ef39045d86b2791a7fae75fe803eff66b4 (patch)
tree451858f9902a212745e1f7e5a8b3f224ebce0baf /test
parentb58e7f412543c2641e2bc8d087fe6836f426cb92 (diff)
[libsanitizer] Use internal_fork() to spawn the symbolizer process.
This should fix https://code.google.com/p/thread-sanitizer/issues/detail?id=61 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208707 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/tsan/pthread_atfork_deadlock.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/tsan/pthread_atfork_deadlock.c b/test/tsan/pthread_atfork_deadlock.c
new file mode 100644
index 000000000..27dff46b9
--- /dev/null
+++ b/test/tsan/pthread_atfork_deadlock.c
@@ -0,0 +1,31 @@
+// RUN: %clang_tsan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// Regression test for
+// https://code.google.com/p/thread-sanitizer/issues/detail?id=61
+// When the data race was reported, pthread_atfork() handler used to be
+// executed which caused another race report in the same thread, which resulted
+// in a deadlock.
+#include <pthread.h>
+#include <stdio.h>
+
+int glob = 0;
+
+void *worker(void *unused) {
+ glob++;
+ return NULL;
+}
+
+void atfork() {
+ fprintf(stderr, "ATFORK\n");
+ glob++;
+}
+
+int main() {
+ pthread_atfork(atfork, NULL, NULL);
+ pthread_t t;
+ pthread_create(&t, NULL, worker, NULL);
+ glob++;
+ pthread_join(t, NULL);
+ // CHECK: ThreadSanitizer: data race
+ // CHECK-NOT: ATFORK
+ return 0;
+}