[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 21:48:13 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL313115: [compiler-rt] Move *Sanitizer:DEADLYSIGNAL printing into common part (authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D37764?vs=114920&id=114968#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37764

Files:
  compiler-rt/trunk/lib/asan/asan_posix.cc
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc


Index: compiler-rt/trunk/lib/asan/asan_posix.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc
+++ compiler-rt/trunk/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/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ compiler-rt/trunk/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) {
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
+++ compiler-rt/trunk/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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37764.114968.patch
Type: text/x-patch
Size: 2502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/08b2e16f/attachment-0001.bin>


More information about the llvm-commits mailing list