[PATCH] Move the signal handling logic into sanitizer_common

Alexey Samsonov samsonov at google.com
Fri Jan 24 04:47:18 PST 2014



================
Comment at: asan/asan_rtl.cc:28
@@ -27,2 +27,3 @@
 #include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_procmaps.h"
 #include "sanitizer_common/sanitizer_symbolizer.h"
----------------
Why this include?

================
Comment at: asan/asan_thread.cc:101
@@ -101,1 +100,3 @@
+  if (common_flags()->use_sigaltstack)
+    __sanitizer::UnsetAlternateSignalStack();
   asanThreadRegistry().FinishThread(tid);
----------------
I think you don't have to explicitly provide __sanitizer:: namespace (here and below).

================
Comment at: asan/asan_posix.cc:36
@@ -36,16 +35,3 @@
 
-static void MaybeInstallSigaction(int signum,
-                                  void (*handler)(int, siginfo_t *, void *)) {
-  if (!AsanInterceptsSignal(signum))
-    return;
-  struct sigaction sigact;
-  REAL(memset)(&sigact, 0, sizeof(sigact));
-  sigact.sa_sigaction = handler;
-  sigact.sa_flags = SA_SIGINFO;
-  if (flags()->use_sigaltstack) sigact.sa_flags |= SA_ONSTACK;
-  CHECK_EQ(0, REAL(sigaction)(signum, &sigact, 0));
-  VReport(1, "Installed the sigaction for signal %d\n", signum);
-}
-
-static void     ASAN_OnSIGSEGV(int, siginfo_t *siginfo, void *context) {
-  uptr addr = (uptr)siginfo->si_addr;
+void ASAN_OnSIGSEGV(int, void *siginfo, void *context) {
+  uptr addr = (uptr)((siginfo_t*)siginfo)->si_addr;
----------------
AsanOnSIGSEGV naming would be more consistent with another function names (same for MSan and TSan)

================
Comment at: interception/interception.h:161
@@ -157,2 +160,3 @@
 # define REAL(x) x
+# define GET_REAL_SLOW(x) x
 # define DECLARE_REAL(ret_type, func, ...) \
----------------
What about GET_REAL_SLOW on Windows?

================
Comment at: sanitizer_common/CMakeLists.txt:76
@@ -75,1 +75,3 @@
 
+include_directories(..)
+
----------------
Why?

================
Comment at: sanitizer_common/sanitizer_common.h:216
@@ -211,1 +215,3 @@
 DieCallbackType GetDieCallback();
+typedef __sanitizer_sighandler_t(*SignalFunctionCallbackType)(
+    int, __sanitizer_sighandler_t);
----------------
Evgeniy Stepanov wrote:
> space before (*
Provide a comment about reasons for adding these functions and their use cases

================
Comment at: sanitizer_common/sanitizer_posix.cc:23
@@ -22,2 +22,3 @@
 
+#include <signal.h>
 #include <sys/mman.h>
----------------
why this include?


http://llvm-reviews.chandlerc.com/D2605



More information about the llvm-commits mailing list