| 1 |
/* { dg-shouldfail "tsan" } */ |
| 2 |
/* { dg-additional-options "-ldl" } */ |
| 3 |
|
| 4 |
#include <pthread.h> |
| 5 |
#include "tsan_barrier.h" |
| 6 |
|
| 7 |
static pthread_barrier_t barrier; |
| 8 |
|
| 9 |
void *Thread(void *a) { |
| 10 |
barrier_wait(&barrier); |
| 11 |
*(int*)a = 43; |
| 12 |
return 0; |
| 13 |
} |
| 14 |
|
| 15 |
int main() { |
| 16 |
barrier_init(&barrier, 2); |
| 17 |
static __thread int Var = 42; |
| 18 |
pthread_t t; |
| 19 |
pthread_create(&t, 0, Thread, &Var); |
| 20 |
Var = 43; |
| 21 |
barrier_wait(&barrier); |
| 22 |
pthread_join(t, 0); |
| 23 |
} |
| 24 |
|
| 25 |
/* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r).*" } */ |
| 26 |
/* { dg-output " Location is TLS of main thread.(\n|\r\n|\r).*" } */ |