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

llvm-svn: 182080
This commit is contained in:
Alexander Potapenko 2013-05-17 08:08:50 +00:00
parent fd8f4b0171
commit 00b44ba778
1 changed files with 9 additions and 1 deletions

View File

@ -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;
}