[PATCH] D30783: [asan] Split SIGSEGV/SIGBUS handling so we can handle only one of them and not the other.

Filipe Cabecinhas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 9 07:51:13 PST 2017


filcab created this revision.

This is useful in some platforms where one of these signals is special.
I'm not sure how to write cross-platform tests for this, though.


https://reviews.llvm.org/D30783

Files:
  lib/sanitizer_common/sanitizer_flags.inc
  lib/sanitizer_common/sanitizer_linux.cc
  lib/sanitizer_common/sanitizer_mac.cc


Index: lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- lib/sanitizer_common/sanitizer_mac.cc
+++ lib/sanitizer_common/sanitizer_mac.cc
@@ -404,7 +404,9 @@
     return true;
   if (common_flags()->handle_sigfpe && signum == SIGFPE)
     return true;
-  return (signum == SIGSEGV || signum == SIGBUS) && common_flags()->handle_segv;
+  if (common_flags()->handle_segv && signum == SIGSEGV)
+    return true;
+  return common_flags()->handle_sigbus && signum == SIGBUS;
 }
 
 MacosVersion cached_macos_version = MACOS_VERSION_UNINITIALIZED;
Index: lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux.cc
+++ lib/sanitizer_common/sanitizer_linux.cc
@@ -1292,7 +1292,9 @@
     return true;
   if (common_flags()->handle_sigfpe && signum == SIGFPE)
     return true;
-  return (signum == SIGSEGV || signum == SIGBUS) && common_flags()->handle_segv;
+  if (common_flags()->handle_segv && signum == SIGSEGV)
+    return true;
+  return common_flags()->handle_sigbus && signum == SIGBUS;
 }
 
 #if !SANITIZER_GO
Index: lib/sanitizer_common/sanitizer_flags.inc
===================================================================
--- lib/sanitizer_common/sanitizer_flags.inc
+++ lib/sanitizer_common/sanitizer_flags.inc
@@ -80,7 +80,9 @@
             "exits, 2 = print after each report.")
 COMMON_FLAG(bool, check_printf, true, "Check printf arguments.")
 COMMON_FLAG(bool, handle_segv, true,
-            "If set, registers the tool's custom SIGSEGV/SIGBUS handler.")
+            "If set, registers the tool's custom SIGSEGV handler.")
+COMMON_FLAG(bool, handle_sigbus, true,
+            "If set, registers the tool's custom SIGBUS handler.")
 COMMON_FLAG(bool, handle_abort, false,
             "If set, registers the tool's custom SIGABRT handler.")
 COMMON_FLAG(bool, handle_sigill, false,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30783.91173.patch
Type: text/x-patch
Size: 1944 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170309/1caea80f/attachment.bin>


More information about the llvm-commits mailing list