tsan: better error message if we fail to intercept some function

currently the message is SIGSEGV

llvm-svn: 169231
This commit is contained in:
Dmitry Vyukov 2012-12-04 07:28:25 +00:00
parent d229abe49a
commit 0d677279f6
2 changed files with 12 additions and 1 deletions

View File

@ -261,7 +261,6 @@ static void finalize(void *arg) {
TSAN_INTERCEPTOR(int, atexit, void (*f)()) {
SCOPED_TSAN_INTERCEPTOR(atexit, f);
return atexit_ctx->atexit(thr, pc, f);
return 0;
}
TSAN_INTERCEPTOR(void, longjmp, void *env, int val) {
@ -1432,6 +1431,11 @@ void ProcessPendingSignals(ThreadState *thr) {
thr->in_signal_handler = false;
}
static void unreachable() {
Printf("FATAL: ThreadSanitizer: unreachable called\n");
Die();
}
void InitializeInterceptors() {
CHECK_GT(cur_thread()->in_rtl, 0);
@ -1566,6 +1570,9 @@ void InitializeInterceptors() {
TSAN_INTERCEPT(mlockall);
TSAN_INTERCEPT(munlockall);
// Need to setup it, because interceptors check that the function is resolved.
// But atexit is emitted directly into the module, so can't be resolved.
REAL(atexit) = (int(*)(void(*)()))unreachable;
atexit_ctx = new(internal_alloc(MBlockAtExit, sizeof(AtExitContext)))
AtExitContext();

View File

@ -42,6 +42,10 @@ class ScopedInterceptor {
#define SCOPED_TSAN_INTERCEPTOR(func, ...) \
SCOPED_INTERCEPTOR_RAW(func, __VA_ARGS__); \
if (REAL(func) == 0) { \
Printf("FATAL: ThreadSanitizer: failed to intercept %s\n", #func); \
Die(); \
} \
if (thr->in_rtl > 1) \
return REAL(func)(__VA_ARGS__); \
/**/