| 1 | // RUN: %clangxx_tsan -O1 -fno-inline-functions %s -o %t && %deflake %run %t | FileCheck %s |
| 2 | #include "test.h" |
| 3 | #include <memory> |
| 4 | |
| 5 | std::unique_ptr<long> global(new long(42)); |
| 6 | |
| 7 | void *thread(void *x) { |
| 8 | *global = 43; |
| 9 | barrier_wait(barrier: &barrier); |
| 10 | return nullptr; |
| 11 | } |
| 12 | |
| 13 | int main() { |
| 14 | barrier_init(barrier: &barrier, count: 2); |
| 15 | pthread_t th; |
| 16 | pthread_create(newthread: &th, attr: nullptr, start_routine: thread, arg: nullptr); |
| 17 | pthread_detach(th: th); |
| 18 | barrier_wait(barrier: &barrier); |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | // CHECK: WARNING: ThreadSanitizer: data race |
| 23 | // CHECK: Write of size 8 |
| 24 | // The exact spelling and number of std frames is hard to guess. |
| 25 | // CHECK: unique_ptr |
| 26 | // CHECK: #{{[1-9]}} cxa_at_exit_callback_installed_at |
| 27 | // CHECK: #{{[2-9]}} __cxx_global_var_init |
| 28 | |