annotate compiler-rt/test/tsan/atexit5.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents
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 -fno-inline-functions %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 <memory>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
4
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
5 std::unique_ptr<long> global(new long(42));
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
6
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
7 void *thread(void *x) {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
8 *global = 43;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
9 barrier_wait(&barrier);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
10 return nullptr;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
11 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
12
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
13 int main() {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
14 barrier_init(&barrier, 2);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
15 pthread_t th;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
16 pthread_create(&th, nullptr, thread, nullptr);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
17 pthread_detach(th);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
18 barrier_wait(&barrier);
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
19 return 0;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
20 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
21
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
22 // CHECK: WARNING: ThreadSanitizer: data race
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
23 // CHECK: Write of size 8
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
24 // The exact spelling and number of std frames is hard to guess.
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
25 // CHECK: unique_ptr
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
26 // CHECK: #{{[1-9]}} cxa_at_exit_callback_installed_at
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
27 // CHECK: #{{[2-9]}} __cxx_global_var_init