From 26c99a3a3e1d07bc58f68d5311697a39a5a6ae7f Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Tue, 31 Oct 2017 11:41:51 -0400 Subject: Fix init-local-signal test (#50) * Add `SA_SIGINFO` flag This is needed to guarantee the availability of the `ucontext` argument * Mark the `NULL` pointer load as `volatile` Further prevent any compiler optimization on the load. --- tests/Ltest-init-local-signal-lib.c | 2 +- tests/Ltest-init-local-signal.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/Ltest-init-local-signal-lib.c b/tests/Ltest-init-local-signal-lib.c index 45c0e7c1..7474f71f 100644 --- a/tests/Ltest-init-local-signal-lib.c +++ b/tests/Ltest-init-local-signal-lib.c @@ -1,6 +1,6 @@ #include /* To prevent inlining and optimizing away */ -int foo(int* f) { +int foo(volatile int* f) { return *f; } diff --git a/tests/Ltest-init-local-signal.c b/tests/Ltest-init-local-signal.c index d23d66f9..4bde218f 100644 --- a/tests/Ltest-init-local-signal.c +++ b/tests/Ltest-init-local-signal.c @@ -46,12 +46,13 @@ void handler(int num, siginfo_t* info, void* ucontext) { exit(-1); } -int foo(int* f); +int foo(volatile int* f); int main(){ struct sigaction a; memset(&a, 0, sizeof(struct sigaction)); a.sa_sigaction = &handler; + a.sa_flags = SA_SIGINFO; sigaction(SIGSEGV, &a, NULL); foo(NULL); -- cgit v1.2.1