1/* { dg-shouldfail "tsan" } */ 2 3#include <pthread.h> 4#include <stdio.h> 5#include <stddef.h> 6#include <unistd.h> 7 8pthread_barrier_t B; 9int Global; 10 11void *Thread1(void *x) { 12 if (pthread_barrier_wait(&B) == PTHREAD_BARRIER_SERIAL_THREAD) 13 pthread_barrier_destroy(&B); 14 return NULL; 15} 16 17void *Thread2(void *x) { 18 if (pthread_barrier_wait(&B) == PTHREAD_BARRIER_SERIAL_THREAD) 19 pthread_barrier_destroy(&B); 20 return NULL; 21} 22 23int main() { 24 pthread_barrier_init(&B, 0, 2); 25 pthread_t t; 26 pthread_create(&t, NULL, Thread1, NULL); 27 Thread2(0); 28 pthread_join(t, NULL); 29 return 0; 30} 31 32/* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */ 33