1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
9 void *Thread1(void *x
) {
10 barrier_wait(&barrier
);
11 int f
= open("/dev/random", O_RDONLY
);
19 void *Thread2(void *x
) {
21 write(STDOUT_FILENO
, "a", 1);
22 barrier_wait(&barrier
);
27 barrier_init(&barrier
, 2);
29 pthread_create(&t
[0], NULL
, Thread1
, NULL
);
30 pthread_create(&t
[1], NULL
, Thread2
, NULL
);
31 pthread_join(t
[0], NULL
);
32 pthread_join(t
[1], NULL
);
35 // CHECK: WARNING: ThreadSanitizer: data race
36 // CHECK: Write of size 4
38 // CHECK: Previous write of size 4