1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
11 void *Thread1(void *x
) {
12 barrier_wait(&barrier
);
17 void *Thread2(void *x
) {
19 barrier_wait(&barrier
);
24 barrier_init(&barrier
, 2);
25 fd
= open("/dev/random", O_RDONLY
);
27 fprintf(stderr
, "failed to open /dev/random (%d)\n", errno
);
31 pthread_create(&t
[0], NULL
, Thread1
, NULL
);
32 pthread_create(&t
[1], NULL
, Thread2
, NULL
);
33 pthread_join(t
[0], NULL
);
34 pthread_join(t
[1], NULL
);
36 fprintf(stderr
, "DONE\n");
39 // CHECK: WARNING: ThreadSanitizer: data race
40 // CHECK: Write of size 1
42 // CHECK: Previous write of size 1