From 00b44ba778478ddb8a8ddc90f90be97766d81490 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Fri, 17 May 2013 08:08:50 +0000 Subject: [PATCH] [ASan] Fix allow_user_segv.cc on Darwin (32-bit build required a SIGBUS handler instead of the SIGSEGV one) llvm-svn: 182080 --- compiler-rt/lib/asan/lit_tests/allow_user_segv.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/asan/lit_tests/allow_user_segv.cc b/compiler-rt/lib/asan/lit_tests/allow_user_segv.cc index 7d5ab9336515..f8aed0d4ca80 100644 --- a/compiler-rt/lib/asan/lit_tests/allow_user_segv.cc +++ b/compiler-rt/lib/asan/lit_tests/allow_user_segv.cc @@ -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; }