diff --git a/compiler-rt/test/tsan/atexit5.cpp b/compiler-rt/test/tsan/atexit5.cpp new file mode 100644 --- /dev/null +++ b/compiler-rt/test/tsan/atexit5.cpp @@ -0,0 +1,26 @@ +// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s +#include "test.h" +#include + +std::unique_ptr global(new long(42)); + +void *thread(void *x) { + *global = 43; + barrier_wait(&barrier); + return nullptr; +} + +int main() { + barrier_init(&barrier, 2); + pthread_t th; + pthread_create(&th, nullptr, thread, nullptr); + pthread_detach(th); + barrier_wait(&barrier); + return 0; +} + +// CHECK: WARNING: ThreadSanitizer: data race +// CHECK: Write of size 8 +// The exact spelling and number of std frames is hard to guess. +// CHECK: unique_ptr +// CHECK: #{{1|2}} cxa_at_exit_wrapper