Index: compiler-rt/lib/lsan/lsan.cc =================================================================== --- compiler-rt/lib/lsan/lsan.cc +++ compiler-rt/lib/lsan/lsan.cc @@ -65,6 +65,21 @@ if (common_flags()->help) parser.PrintFlagDescriptions(); } +static void OnStackUnwind(const SignalContext &sig, const void *, + BufferedStackTrace *stack) { + GetStackTraceWithPcBpAndContext(stack, kStackTraceMax, sig.pc, sig.bp, + sig.context, + common_flags()->fast_unwind_on_fatal); +} + +void LsanOnDeadlySignal(int signo, void *siginfo, void *context) { + StartReportDeadlySignal(); + SpinMutexLock l(&CommonSanitizerReportMutex); + SignalContext sig(siginfo, context); + ReportDeadlySignal(sig, GetCurrentThread(), &OnStackUnwind, nullptr); + Die(); +} + extern "C" void __lsan_init() { CHECK(!lsan_init_is_running); if (lsan_inited) @@ -80,6 +95,7 @@ InitTlsSize(); InitializeInterceptors(); InitializeThreadRegistry(); + InstallDeadlySignalHandlers(LsanOnDeadlySignal); u32 tid = ThreadCreate(0, 0, true); CHECK_EQ(tid, 0); ThreadStart(tid, GetTid()); Index: compiler-rt/lib/lsan/lsan_interceptors.cc =================================================================== --- compiler-rt/lib/lsan/lsan_interceptors.cc +++ compiler-rt/lib/lsan/lsan_interceptors.cc @@ -401,9 +401,14 @@ REAL(_exit)(status); } +#define COMMON_INTERCEPT_FUNCTION(name) INTERCEPT_FUNCTION(name) +#include "sanitizer_common/sanitizer_signal_interceptors.inc" + namespace __lsan { void InitializeInterceptors() { + InitializeSignalInterceptors(); + INTERCEPT_FUNCTION(malloc); INTERCEPT_FUNCTION(free); LSAN_MAYBE_INTERCEPT_CFREE; Index: compiler-rt/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc +++ compiler-rt/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc @@ -18,7 +18,6 @@ // clang-format on // Remove when fixed: https://github.com/google/sanitizers/issues/637 -// XFAIL: lsan // XFAIL: msan // XFAIL: tsan // XFAIL: ubsan Index: compiler-rt/test/sanitizer_common/TestCases/Linux/assert.cc =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Linux/assert.cc +++ compiler-rt/test/sanitizer_common/TestCases/Linux/assert.cc @@ -7,11 +7,11 @@ // RUN: %env_tool_opts=handle_abort=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s // clang-format on -// FIXME: implement in other sanitizers, not just asan. +// FIXME: implement in other sanitizers. // XFAIL: msan -// XFAIL: lsan // XFAIL: tsan // XFAIL: ubsan + #include #include #include Index: compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc +++ compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc @@ -7,9 +7,8 @@ // RUN: %env_tool_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s // clang-format on -// FIXME: implement in other sanitizers, not just asan. +// FIXME: implement in other sanitizers. // XFAIL: msan -// XFAIL: lsan // XFAIL: tsan // XFAIL: ubsan // Index: compiler-rt/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc +++ compiler-rt/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cc @@ -9,7 +9,6 @@ // REQUIRES: stable-runtime // FIXME: implement SEGV handler in other sanitizers, not just asan. // XFAIL: msan -// XFAIL: lsan // XFAIL: tsan // XFAIL: ubsan Index: compiler-rt/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc +++ compiler-rt/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cc @@ -8,7 +8,10 @@ // clang-format on // REQUIRES: x86-target-arch -// XFAIL: lsan, msan, tsan, ubsan +// FIXME: implement in other sanitizers. +// XFAIL: msan +// XFAIL: tsan +// XFAIL: ubsan int main() { #if defined(__x86_64__) Index: compiler-rt/test/sanitizer_common/TestCases/Posix/fpe.cc =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Posix/fpe.cc +++ compiler-rt/test/sanitizer_common/TestCases/Posix/fpe.cc @@ -5,7 +5,6 @@ // 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: lsan // XFAIL: tsan // XFAIL: ubsan // Index: compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc +++ compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_fd_test.cc @@ -7,7 +7,6 @@ // REQUIRES: stable-runtime // FIXME: implement SEGV handler in other sanitizers, not just asan. // XFAIL: msan -// XFAIL: lsan // XFAIL: tsan // XFAIL: ubsan