Index: compiler-rt/trunk/lib/msan/msan.cc =================================================================== --- compiler-rt/trunk/lib/msan/msan.cc +++ compiler-rt/trunk/lib/msan/msan.cc @@ -369,6 +369,16 @@ Die(); } +static void OnStackUnwind(const SignalContext &sig, const void *, + BufferedStackTrace *stack) { + GetStackTrace(stack, kStackTraceMax, sig.pc, sig.bp, sig.context, + common_flags()->fast_unwind_on_fatal); +} + +static void MsanOnDeadlySignal(int signo, void *siginfo, void *context) { + HandleDeadlySignal(siginfo, context, GetTid(), &OnStackUnwind, nullptr); +} + void __msan_init() { CHECK(!msan_init_is_running); if (msan_inited) return; @@ -384,6 +394,7 @@ __sanitizer_set_report_path(common_flags()->log_path); InitializeInterceptors(); + InstallDeadlySignalHandlers(MsanOnDeadlySignal); InstallAtExitHandler(); // Needs __cxa_atexit interceptor. DisableCoreDumperIfNecessary(); Index: compiler-rt/trunk/lib/msan/msan_interceptors.cc =================================================================== --- compiler-rt/trunk/lib/msan/msan_interceptors.cc +++ compiler-rt/trunk/lib/msan/msan_interceptors.cc @@ -1006,20 +1006,6 @@ CHECK_UNPOISONED(&act->sa_mask, sizeof(act->sa_mask)); } -static int sigaction_impl(int signo, const __sanitizer_sigaction *act, - __sanitizer_sigaction *oldact); -static uptr signal_impl(int signo, uptr cb); - -INTERCEPTOR(int, sigaction, int signo, const __sanitizer_sigaction *act, - __sanitizer_sigaction *oldact) { - return sigaction_impl(signo, act, oldact); -} - -INTERCEPTOR(int, signal, int signo, uptr cb) { - cb = signal_impl(signo, cb); - return REAL(signal)(signo, cb); -} - extern "C" int pthread_attr_init(void *attr); extern "C" int pthread_attr_destroy(void *attr); @@ -1275,6 +1261,20 @@ #include "sanitizer_common/sanitizer_platform_interceptors.h" #include "sanitizer_common/sanitizer_common_interceptors.inc" +static uptr signal_impl(int signo, uptr cb); +static int sigaction_impl(int signo, const __sanitizer_sigaction *act, + __sanitizer_sigaction *oldact); + +#define SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signo, act, oldact) \ + { return sigaction_impl(signo, act, oldact); } + +#define SIGNAL_INTERCEPTOR_SIGNAL_IMPL(func, signo, handler) \ + { \ + handler = signal_impl(signo, handler); \ + return REAL(func)(signo, handler); \ + } + +#include "sanitizer_common/sanitizer_signal_interceptors.inc" static int sigaction_impl(int signo, const __sanitizer_sigaction *act, __sanitizer_sigaction *oldact) { @@ -1490,6 +1490,7 @@ static int inited = 0; CHECK_EQ(inited, 0); InitializeCommonInterceptors(); + InitializeSignalInterceptors(); INTERCEPT_FUNCTION(mmap); MSAN_MAYBE_INTERCEPT_MMAP64; Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc @@ -8,7 +8,6 @@ // clang-format on // FIXME: implement in other sanitizers. -// XFAIL: msan // XFAIL: tsan #include Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc @@ -8,7 +8,6 @@ // clang-format on // FIXME: implement in other sanitizers. -// XFAIL: msan // XFAIL: tsan // XFAIL: ubsan // Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc @@ -8,7 +8,6 @@ // REQUIRES: stable-runtime // FIXME: implement SEGV handler in other sanitizers. -// XFAIL: msan // XFAIL: tsan volatile int *null = 0; Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc @@ -9,7 +9,6 @@ // REQUIRES: x86-target-arch // FIXME: implement in other sanitizers. -// XFAIL: msan // XFAIL: tsan int main() { Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc @@ -4,7 +4,6 @@ // RUN: %env_tool_opts=handle_sigfpe=0 not --crash %run %t 2>&1 | FileCheck --check-prefix=CHECK0 %s // RUN: %env_tool_opts=handle_sigfpe=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s // FIXME: implement in other sanitizers, not just asan. -// XFAIL: msan // XFAIL: tsan // XFAIL: ubsan // Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc @@ -7,7 +7,6 @@ // REQUIRES: stable-runtime // XFAIL: android && asan // FIXME: implement SEGV handler in other sanitizers, not just asan. -// XFAIL: msan // XFAIL: tsan #include