[compiler-rt] r182080 - [ASan] Fix allow_user_segv.cc on Darwin (32-bit build required a SIGBUS handler instead of the SIGSEGV one)

Alexander Potapenko glider at google.com
Fri May 17 01:08:51 PDT 2013


Author: glider
Date: Fri May 17 03:08:50 2013
New Revision: 182080

URL: http://llvm.org/viewvc/llvm-project?rev=182080&view=rev
Log:
[ASan] Fix allow_user_segv.cc on Darwin (32-bit build required a SIGBUS handler instead of the SIGSEGV one)

Modified:
    compiler-rt/trunk/lib/asan/lit_tests/allow_user_segv.cc

Modified: compiler-rt/trunk/lib/asan/lit_tests/allow_user_segv.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/allow_user_segv.cc?rev=182080&r1=182079&r2=182080&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/allow_user_segv.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/allow_user_segv.cc Fri May 17 03:08:50 2013
@@ -28,7 +28,15 @@ int DoSEGV() {
 int main() {
   user_sigaction.sa_sigaction = User_OnSIGSEGV;
   user_sigaction.sa_flags = SA_SIGINFO;
-  if (sigaction(SIGSEGV, &user_sigaction, &original_sigaction)) {
+#if defined(__APPLE__) && !defined(__LP64__)
+  // On 32-bit Darwin KERN_PROTECTION_FAILURE (SIGBUS) is delivered.
+  int signum = SIGBUS;
+#else
+  // On 64-bit Darwin KERN_INVALID_ADDRESS (SIGSEGV) is delivered.
+  // On Linux SIGSEGV is delivered as well.
+  int signum = SIGSEGV;
+#endif
+  if (sigaction(signum, &user_sigaction, &original_sigaction)) {
     perror("sigaction");
     return 1;
   }





More information about the llvm-commits mailing list