summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/asan
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2014-11-05 18:58:41 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2014-11-05 18:58:41 +0000
commitfe4e7c17165dd0ebd80a78023598d442911f0495 (patch)
treef756c6a3a01b7ce9c99cb182ce7d80869149700f /compiler-rt/test/asan
parent0078cea79251768a02f9ea5a9a8db1d0991ddb17 (diff)
downloadbcm5719-llvm-fe4e7c17165dd0ebd80a78023598d442911f0495.tar.gz
bcm5719-llvm-fe4e7c17165dd0ebd80a78023598d442911f0495.zip
Fix failing allow_user_segv.cc test on OS X 10.10
The current ASan testcase Posix/allow_user_segv.cc expects SIGBUS to be triggered on 32-bit Darwin. This has apparently changed on 10.10 to trigger SIGSEGV instead, just as on 64-bit. Let's just install handlers for both SIGSEGV and SIGBUS instead of #ifdef'ing. Reviewed at http://reviews.llvm.org/D6121 llvm-svn: 221381
Diffstat (limited to 'compiler-rt/test/asan')
-rw-r--r--compiler-rt/test/asan/TestCases/Posix/allow_user_segv.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/compiler-rt/test/asan/TestCases/Posix/allow_user_segv.cc b/compiler-rt/test/asan/TestCases/Posix/allow_user_segv.cc
index 1768643ddd3..b6443fab85d 100644
--- a/compiler-rt/test/asan/TestCases/Posix/allow_user_segv.cc
+++ b/compiler-rt/test/asan/TestCases/Posix/allow_user_segv.cc
@@ -6,12 +6,22 @@
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
-struct sigaction user_sigaction;
-struct sigaction original_sigaction;
+struct sigaction original_sigaction_sigbus;
+struct sigaction original_sigaction_sigsegv;
void User_OnSIGSEGV(int signum, siginfo_t *siginfo, void *context) {
fprintf(stderr, "User sigaction called\n");
+ struct sigaction original_sigaction;
+ if (signum == SIGBUS)
+ original_sigaction = original_sigaction_sigbus;
+ else if (signum == SIGSEGV)
+ original_sigaction = original_sigaction_sigsegv;
+ else {
+ printf("Invalid signum");
+ exit(1);
+ }
if (original_sigaction.sa_flags | SA_SIGINFO)
original_sigaction.sa_sigaction(signum, siginfo, context);
else
@@ -23,21 +33,22 @@ int DoSEGV() {
return *x;
}
-int main() {
+int InstallHandler(int signum, struct sigaction *original_sigaction) {
+ struct sigaction user_sigaction;
user_sigaction.sa_sigaction = User_OnSIGSEGV;
user_sigaction.sa_flags = SA_SIGINFO;
-#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)) {
+ if (sigaction(signum, &user_sigaction, original_sigaction)) {
perror("sigaction");
return 1;
}
+ return 0;
+}
+
+int main() {
+ // Let's install handlers for both SIGSEGV and SIGBUS, since pre-Yosemite
+ // 32-bit Darwin triggers SIGBUS instead.
+ if (InstallHandler(SIGSEGV, &original_sigaction_sigsegv)) return 1;
+ if (InstallHandler(SIGBUS, &original_sigaction_sigbus)) return 1;
fprintf(stderr, "User sigaction installed\n");
return DoSEGV();
}
OpenPOWER on IntegriCloud