
dlsym calls into dynamic linker which calls malloc and other things. It's problematic to do it during the actual exit, because it can happen from a singal handler or from within the runtime after we reported the first bug, etc. See https://github.com/google/sanitizers/issues/1440 for an example (captured in the added test). Initialize the callbacks during startup instead. Depends on D110159. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D110166
23 lines
502 B
C++
23 lines
502 B
C++
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
|
|
#include "test.h"
|
|
#include <signal.h>
|
|
#include <sys/types.h>
|
|
|
|
static void handler(int, siginfo_t *, void *) {
|
|
write(2, "SIGNAL\n", 7);
|
|
// CHECK: SIGNAL
|
|
_exit(0);
|
|
// CHECK-NOT: ThreadSanitizer: signal-unsafe call
|
|
}
|
|
|
|
int main() {
|
|
struct sigaction act = {};
|
|
act.sa_sigaction = &handler;
|
|
act.sa_flags = SA_SIGINFO;
|
|
sigaction(SIGPROF, &act, 0);
|
|
raise(SIGPROF);
|
|
fprintf(stderr, "DONE\n");
|
|
// CHECK-NOT: DONE
|
|
return 0;
|
|
}
|