annotate compiler-rt/test/tsan/fd_close_race.cpp @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents c4bab56944e8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
236
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
2 #include "test.h"
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
3 #include <fcntl.h>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
4 #include <sys/stat.h>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
5 #include <sys/types.h>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
6
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
7 void *Thread(void *arg) {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
8 char buf;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
9 read((long)arg, &buf, 1);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
10 barrier_wait(&barrier);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
11 return NULL;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
12 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
13
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
14 int main() {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
15 barrier_init(&barrier, 2);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
16 int fd = open("/dev/random", O_RDONLY);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
17 pthread_t t;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
18 pthread_create(&t, NULL, Thread, (void *)(long)fd);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
19 barrier_wait(&barrier);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
20 close(fd);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
21 pthread_join(t, NULL);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
22 fprintf(stderr, "DONE\n");
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
23 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
24
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
25 // CHECK: WARNING: ThreadSanitizer: data race
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
26 // CHECK: DONE