diff options
author | Yichao Yu <yyc1992@gmail.com> | 2017-10-31 11:41:51 -0400 |
---|---|---|
committer | Dave Watson <davejwatson@fb.com> | 2017-10-31 08:41:51 -0700 |
commit | 26c99a3a3e1d07bc58f68d5311697a39a5a6ae7f (patch) | |
tree | 17d65f2c5569f4cb9289b40ab8a77e961b5fcaf9 /tests | |
parent | b9fe811de958d605394f243e950fd8fcf0d3441e (diff) | |
download | libunwind-26c99a3a3e1d07bc58f68d5311697a39a5a6ae7f.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Ltest-init-local-signal-lib.c | 2 | ||||
-rw-r--r-- | tests/Ltest-init-local-signal.c | 3 |
2 files changed, 3 insertions, 2 deletions
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 <stdio.h> /* 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); |