[compiler-rt] r317864 - [msan] Deadly signal handler for msan
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 9 18:06:59 PST 2017
Author: vitalybuka
Date: Thu Nov 9 18:06:59 2017
New Revision: 317864
URL: http://llvm.org/viewvc/llvm-project?rev=317864&view=rev
Log:
[msan] Deadly signal handler for msan
Summary: Part of https://github.com/google/sanitizers/issues/637
Reviewers: eugenis, alekseyshl
Subscribers: llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D39826
Modified:
compiler-rt/trunk/lib/msan/msan.cc
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc
compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc
compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc
compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc
compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc
compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc
Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=317864&r1=317863&r2=317864&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Thu Nov 9 18:06:59 2017
@@ -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();
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=317864&r1=317863&r2=317864&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Thu Nov 9 18:06:59 2017
@@ -1006,20 +1006,6 @@ static void read_sigaction(const __sanit
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;
Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc?rev=317864&r1=317863&r2=317864&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/assert.cc Thu Nov 9 18:06:59 2017
@@ -8,7 +8,6 @@
// clang-format on
// FIXME: implement in other sanitizers.
-// XFAIL: msan
// XFAIL: tsan
#include <assert.h>
Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc?rev=317864&r1=317863&r2=317864&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ill.cc Thu Nov 9 18:06:59 2017
@@ -8,7 +8,6 @@
// clang-format on
// FIXME: implement in other sanitizers.
-// XFAIL: msan
// XFAIL: tsan
// XFAIL: ubsan
//
Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc?rev=317864&r1=317863&r2=317864&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc Thu Nov 9 18:06:59 2017
@@ -8,7 +8,6 @@
// REQUIRES: stable-runtime
// FIXME: implement SEGV handler in other sanitizers.
-// XFAIL: msan
// XFAIL: tsan
volatile int *null = 0;
Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc?rev=317864&r1=317863&r2=317864&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc Thu Nov 9 18:06:59 2017
@@ -9,7 +9,6 @@
// REQUIRES: x86-target-arch
// FIXME: implement in other sanitizers.
-// XFAIL: msan
// XFAIL: tsan
int main() {
Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc?rev=317864&r1=317863&r2=317864&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fpe.cc Thu Nov 9 18:06:59 2017
@@ -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
//
Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc?rev=317864&r1=317863&r2=317864&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc Thu Nov 9 18:06:59 2017
@@ -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>
More information about the llvm-commits
mailing list