Override __cxa_atexit and ignore callbacks. This prevents crashes in a configuration when the symbolizer is built into sanitizer runtime and consequently into the test process. LLVM libraries have some global objects destroyed during exit, so if the test process triggers any bugs after that, the symbolizer crashes. An example stack trace of such crash: For the standalone llvm-symbolizer this does not hurt, we just don't destroy few global objects on exit. Reviewed By: kda Differential Revision: https://reviews.llvm.org/D102470
30 lines
531 B
C++
30 lines
531 B
C++
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
|
|
#include "test.h"
|
|
|
|
void *thread(void *x) {
|
|
barrier_wait(&barrier);
|
|
*static_cast<int *>(x) = 2;
|
|
return nullptr;
|
|
}
|
|
|
|
static void race() {
|
|
int data = 0;
|
|
pthread_t t;
|
|
pthread_create(&t, nullptr, thread, &data);
|
|
data = 1;
|
|
barrier_wait(&barrier);
|
|
pthread_join(t, nullptr);
|
|
}
|
|
|
|
struct X {
|
|
X() { atexit(race); }
|
|
} x;
|
|
|
|
int main() {
|
|
barrier_init(&barrier, 2);
|
|
fprintf(stderr, "DONE\n");
|
|
}
|
|
|
|
// CHECK: DONE
|
|
// CHECK: WARNING: ThreadSanitizer: data race
|