[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / tsan / fd_pipe_race.cc
blob4dd2b77861ab112b025eb4cd795114d3d1d6645d
1 // RUN: %clangxx_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <unistd.h>
6 int fds[2];
8 void *Thread1(void *x) {
9 write(fds[1], "a", 1);
10 return NULL;
13 void *Thread2(void *x) {
14 sleep(1);
15 close(fds[0]);
16 close(fds[1]);
17 return NULL;
20 int main() {
21 pipe(fds);
22 pthread_t t[2];
23 pthread_create(&t[0], NULL, Thread1, NULL);
24 pthread_create(&t[1], NULL, Thread2, NULL);
25 pthread_join(t[0], NULL);
26 pthread_join(t[1], NULL);
29 // CHECK: WARNING: ThreadSanitizer: data race
30 // CHECK: Write of size 8
31 // CHECK: #0 close
32 // CHECK: #1 Thread2
33 // CHECK: Previous read of size 8
34 // CHECK: #0 write
35 // CHECK: #1 Thread1