Index: compiler-rt/lib/asan/asan_posix.cc =================================================================== --- compiler-rt/lib/asan/asan_posix.cc +++ compiler-rt/lib/asan/asan_posix.cc @@ -35,11 +35,7 @@ void AsanOnDeadlySignal(int signo, void *siginfo, void *context) { ScopedDeadlySignal signal_scope(GetCurrentThread()); - // Write the first message using fd=2, just in case. - // It may actually fail to write in case stderr is closed. - internal_write(2, SanitizerToolName, internal_strlen(SanitizerToolName)); - static const char kDeadlySignal[] = ":DEADLYSIGNAL\n"; - internal_write(2, kDeadlySignal, sizeof(kDeadlySignal) - 1); + StartReportDeadlySignal(); SignalContext sig = SignalContext::Create(siginfo, context); if (IsStackOverflow(((siginfo_t *)siginfo)->si_code, sig)) ReportStackOverflow(sig); Index: compiler-rt/lib/sanitizer_common/sanitizer_common.h =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_common.h +++ compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -308,9 +308,11 @@ // Functions related to signal handling. typedef void (*SignalHandlerType)(int, void *, void *); HandleSignalMode GetHandleSignalMode(int signum); -bool IsStackOverflow(int code, const SignalContext &sig); void InstallDeadlySignalHandlers(SignalHandlerType handler); const char *DescribeSignalOrException(int signo); +// Signal reporting. +void StartReportDeadlySignal(); +bool IsStackOverflow(int code, const SignalContext &sig); // Alternative signal stack (POSIX-only). void SetAlternateSignalStack(); void UnsetAlternateSignalStack(); Index: compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc +++ compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc @@ -260,6 +260,14 @@ return IsStackAccess && (code == si_SEGV_MAPERR || code == si_SEGV_ACCERR); } +void StartReportDeadlySignal() { + // Write the first message using fd=2, just in case. + // It may actually fail to write in case stderr is closed. + internal_write(2, SanitizerToolName, internal_strlen(SanitizerToolName)); + static const char kDeadlySignal[] = ":DEADLYSIGNAL\n"; + internal_write(2, kDeadlySignal, sizeof(kDeadlySignal) - 1); +} + #endif // SANITIZER_GO bool IsAccessibleMemoryRange(uptr beg, uptr size) {