summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/msan/msan.cc11
-rw-r--r--lib/msan/msan_interceptors.cc29
-rw-r--r--test/sanitizer_common/TestCases/Linux/assert.cc1
-rw-r--r--test/sanitizer_common/TestCases/Linux/ill.cc1
-rw-r--r--test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc1
-rw-r--r--test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc1
-rw-r--r--test/sanitizer_common/TestCases/Posix/fpe.cc1
-rw-r--r--test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc1
8 files changed, 26 insertions, 20 deletions
diff --git a/lib/msan/msan.cc b/lib/msan/msan.cc
index 3f85a9a66..e6226ba76 100644
--- a/lib/msan/msan.cc
+++ b/lib/msan/msan.cc
@@ -369,6 +369,16 @@ void __msan_warning_noreturn() {
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 @@ void __msan_init() {
__sanitizer_set_report_path(common_flags()->log_path);
InitializeInterceptors();
+ InstallDeadlySignalHandlers(MsanOnDeadlySignal);
InstallAtExitHandler(); // Needs __cxa_atexit interceptor.
DisableCoreDumperIfNecessary();
diff --git a/lib/msan/msan_interceptors.cc b/lib/msan/msan_interceptors.cc
index feae876fd..f5822db28 100644
--- a/lib/msan/msan_interceptors.cc
+++ b/lib/msan/msan_interceptors.cc
@@ -1006,20 +1006,6 @@ static void read_sigaction(const __sanitizer_sigaction *act) {
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 @@ int OnExit() {
#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 @@ void InitializeInterceptors() {
static int inited = 0;
CHECK_EQ(inited, 0);
InitializeCommonInterceptors();
+ InitializeSignalInterceptors();
INTERCEPT_FUNCTION(mmap);
MSAN_MAYBE_INTERCEPT_MMAP64;
diff --git a/test/sanitizer_common/TestCases/Linux/assert.cc b/test/sanitizer_common/TestCases/Linux/assert.cc
index f10ddf3ce..76069f9e9 100644
--- a/test/sanitizer_common/TestCases/Linux/assert.cc
+++ b/test/sanitizer_common/TestCases/Linux/assert.cc
@@ -8,7 +8,6 @@
// clang-format on
// FIXME: implement in other sanitizers.
-// XFAIL: msan
// XFAIL: tsan
#include <assert.h>
diff --git a/test/sanitizer_common/TestCases/Linux/ill.cc b/test/sanitizer_common/TestCases/Linux/ill.cc
index 7d39abefa..47a278387 100644
--- a/test/sanitizer_common/TestCases/Linux/ill.cc
+++ b/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
//
diff --git a/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc b/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc
index 7e93af46d..e1192c765 100644
--- a/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc
+++ b/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;
diff --git a/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc b/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc
index 25e801a10..4e5dc6d08 100644
--- a/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc
+++ b/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() {
diff --git a/test/sanitizer_common/TestCases/Posix/fpe.cc b/test/sanitizer_common/TestCases/Posix/fpe.cc
index 46fe4f439..4f887b5f1 100644
--- a/test/sanitizer_common/TestCases/Posix/fpe.cc
+++ b/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
//
diff --git a/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc b/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc
index baa1d9a64..911901098 100644
--- a/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc
+++ b/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 <sanitizer/common_interface_defs.h>