diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2013-10-03 14:00:46 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2013-10-03 14:00:46 +0000 |
commit | c78140f0bd5d6b44a2a30d82879480c592f10d52 (patch) | |
tree | 850827bf733a4286a1a7883b9ccdedd0207a2692 /lib/tsan/rtl/tsan_interceptors.cc | |
parent | 4af0f21c0c98950df1136dbec8824a029ed5bb8e (diff) | |
download | compiler-rt-c78140f0bd5d6b44a2a30d82879480c592f10d52.tar.gz compiler-rt-c78140f0bd5d6b44a2a30d82879480c592f10d52.tar.bz2 compiler-rt-c78140f0bd5d6b44a2a30d82879480c592f10d52.tar.xz |
tsan: intercept _exit so that we can override exit status
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191898 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_interceptors.cc')
-rw-r--r-- | lib/tsan/rtl/tsan_interceptors.cc | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors.cc index c4bde58f..eebdf3e5 100644 --- a/lib/tsan/rtl/tsan_interceptors.cc +++ b/lib/tsan/rtl/tsan_interceptors.cc @@ -1958,8 +1958,27 @@ static void syscall_post_fork(uptr pc, int res) { syscall_post_fork(GET_CALLER_PC(), res) #include "sanitizer_common/sanitizer_common_syscalls.inc" +TSAN_INTERCEPTOR(void, _exit, int status) { + ThreadState * thr = cur_thread(); + int status1 = Finalize(thr); + REAL(fflush)(0); + if (status == 0) + status = status1; + REAL(_exit)(status); +} + namespace __tsan { +static void finalize(void *arg) { + ThreadState * thr = cur_thread(); + uptr pc = 0; + atexit_ctx->exit(thr, pc); + int status = Finalize(thr); + REAL(fflush)(0); + if (status) + REAL(_exit)(status); +} + void ProcessPendingSignals(ThreadState *thr) { CHECK_EQ(thr->in_rtl, 0); SignalContext *sctx = SigCtx(thr); @@ -2009,16 +2028,6 @@ void ProcessPendingSignals(ThreadState *thr) { thr->in_signal_handler = false; } -static void finalize(void *arg) { - ThreadState * thr = cur_thread(); - uptr pc = 0; - atexit_ctx->exit(thr, pc); - int status = Finalize(cur_thread()); - REAL(fflush)(0); - if (status) - _exit(status); -} - static void unreachable() { Printf("FATAL: ThreadSanitizer: unreachable called\n"); Die(); @@ -2199,6 +2208,7 @@ void InitializeInterceptors() { TSAN_INTERCEPT(dlclose); TSAN_INTERCEPT(on_exit); TSAN_INTERCEPT(__cxa_atexit); + TSAN_INTERCEPT(_exit); // 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. |