aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/pthread_atfork_deadlock.c
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-02-10 07:45:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-02-10 07:45:43 +0000
commit476c4db3dc56bee43df384704c75ccc71cfa7a1d (patch)
tree5d0dcec3cc12fc53532fc84029892b98711a2596 /test/tsan/pthread_atfork_deadlock.c
parentca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (diff)
downloadsrc-476c4db3dc56bee43df384704c75ccc71cfa7a1d.tar.gz
src-476c4db3dc56bee43df384704c75ccc71cfa7a1d.zip
Import compiler-rt trunk r228651.vendor/compiler-rt/compiler-rt-r228651
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=278497 svn path=/vendor/compiler-rt/compiler-rt-r228651/; revision=278498; tag=vendor/compiler-rt/compiler-rt-r228651
Diffstat (limited to 'test/tsan/pthread_atfork_deadlock.c')
-rw-r--r--test/tsan/pthread_atfork_deadlock.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/tsan/pthread_atfork_deadlock.c b/test/tsan/pthread_atfork_deadlock.c
index 0f33b9022e5f..4aeec82b6850 100644
--- a/test/tsan/pthread_atfork_deadlock.c
+++ b/test/tsan/pthread_atfork_deadlock.c
@@ -4,14 +4,12 @@
// 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>
-#include <unistd.h>
+#include "test.h"
int glob = 0;
void *worker(void *unused) {
- sleep(1);
+ barrier_wait(&barrier);
glob++;
return NULL;
}
@@ -22,10 +20,12 @@ void atfork() {
}
int main() {
+ barrier_init(&barrier, 2);
pthread_atfork(atfork, NULL, NULL);
pthread_t t;
pthread_create(&t, NULL, worker, NULL);
glob++;
+ barrier_wait(&barrier);
pthread_join(t, NULL);
// CHECK: ThreadSanitizer: data race
// CHECK-NOT: ATFORK