[PATCH] D37764: [compiler-rt] Move *Sanitizer:DEADLYSIGNAL printing into common part
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 12 13:42:33 PDT 2017
vitalybuka created this revision.
Herald added subscribers: dberris, kubamracek.
Part of https://github.com/google/sanitizers/issues/637
https://reviews.llvm.org/D37764
Files:
compiler-rt/lib/asan/asan_posix.cc
compiler-rt/lib/sanitizer_common/sanitizer_common.h
compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc
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
@@ -215,6 +215,7 @@
MaybeInstallSigaction(SIGFPE, handler);
MaybeInstallSigaction(SIGILL, handler);
}
+
#endif // SANITIZER_GO
bool IsAccessibleMemoryRange(uptr beg, uptr size) {
Index: compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
+++ compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
@@ -322,6 +322,7 @@
}
#if !SANITIZER_GO
+
bool IsStackOverflow(int code, const SignalContext &sig) {
// Access at a reasonable offset above SP, or slightly below it (to account
// for x86_64 or PowerPC redzone, ARM push of multiple registers, etc) is
@@ -366,8 +367,17 @@
// unaligned memory access.
return IsStackAccess && (code == si_SEGV_MAPERR || code == si_SEGV_ACCERR);
}
+
#endif //! SANITIZER_GO
+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);
+}
+
} // namespace __sanitizer
#endif // SANITIZER_POSIX
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/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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37764.114898.patch
Type: text/x-patch
Size: 3176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170912/f21671fd/attachment.bin>
More information about the llvm-commits
mailing list