1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
6 void *Thread(void *x
) {
10 barrier_wait(&barrier
);
16 barrier_init(&barrier
, 2);
17 int fd
= open("/dev/random", O_RDONLY
);
19 pthread_create(&t
[0], NULL
, Thread
, (void *)(long)fd
);
20 pthread_create(&t
[1], NULL
, Thread
, (void *)(long)fd
);
22 pthread_join(t
[0], NULL
);
23 pthread_join(t
[1], NULL
);
26 // CHECK: WARNING: ThreadSanitizer: data race
27 // CHECK: Location is file descriptor {{[0-9]+}} {{(destroyed by thread|created by main)}}
28 // CHECK: #0 {{close|open}}
29 // CHECK: #1 {{Thread|main}}