diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-02-10 07:45:43 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-02-10 07:45:43 +0000 |
commit | 476c4db3dc56bee43df384704c75ccc71cfa7a1d (patch) | |
tree | 5d0dcec3cc12fc53532fc84029892b98711a2596 /test/tsan/cond_race.cc | |
parent | ca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (diff) |
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/cond_race.cc')
-rw-r--r-- | test/tsan/cond_race.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/test/tsan/cond_race.cc b/test/tsan/cond_race.cc index fa42fafca4d2..52654f16e85c 100644 --- a/test/tsan/cond_race.cc +++ b/test/tsan/cond_race.cc @@ -3,10 +3,7 @@ // CHECK: ThreadSanitizer: data race // CHECK: pthread_cond_signal -#include <stdio.h> -#include <stdlib.h> -#include <pthread.h> -#include <unistd.h> +#include "test.h" struct Ctx { pthread_mutex_t m; @@ -20,10 +17,12 @@ void *thr(void *p) { c->done = true; pthread_mutex_unlock(&c->m); pthread_cond_signal(&c->c); + barrier_wait(&barrier); return 0; } int main() { + barrier_init(&barrier, 2); Ctx *c = new Ctx(); pthread_mutex_init(&c->m, 0); pthread_cond_init(&c->c, 0); @@ -33,8 +32,8 @@ int main() { while (!c->done) pthread_cond_wait(&c->c, &c->m); pthread_mutex_unlock(&c->m); - // w/o this sleep, it can be reported as use-after-free - sleep(1); + // otherwise it can be reported as use-after-free + barrier_wait(&barrier); delete c; pthread_join(th, 0); } |