diff options
author | Vitaly Buka <vitalybuka@google.com> | 2019-10-02 21:20:37 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2019-10-02 21:20:37 +0000 |
commit | 177d0c91d6f86adfca2f466141c7a4532209935f (patch) | |
tree | 7fe1d35fb91f5707cdf020dca8284d1abb7671b0 /test/sanitizer_common/TestCases/Linux | |
parent | ade11291cd1f477fcd0c20a0448237e671932442 (diff) | |
download | compiler-rt-177d0c91d6f86adfca2f466141c7a4532209935f.tar.gz |
[compiler-rt] Use GetNextInstructionPc in signal handlers
Summary:
All other stack trace callers assume that PC contains return address.
HWAsan already use GetNextInstructionPc in similar code.
PR43339
Reviewers: eugenis, kcc, jfb
Subscribers: dexonsmith, dberris, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D68313
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@373529 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/sanitizer_common/TestCases/Linux')
-rw-r--r-- | test/sanitizer_common/TestCases/Linux/signal_line.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/Linux/signal_line.cpp b/test/sanitizer_common/TestCases/Linux/signal_line.cpp new file mode 100644 index 000000000..57175effe --- /dev/null +++ b/test/sanitizer_common/TestCases/Linux/signal_line.cpp @@ -0,0 +1,36 @@ +// Test line numbers in signal handlers + +// RUN: %clangxx %s -o %t -O0 +// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 1 2>&1 | FileCheck --check-prefixes=CHECK1,CHECK %s +// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 2 2>&1 | FileCheck --check-prefixes=CHECK2,CHECK %s +// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 3 2>&1 | FileCheck --check-prefixes=CHECK3,CHECK %s +// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 4 2>&1 | FileCheck --check-prefixes=CHECK4,CHECK %s + +#include <cstdio> +#include <string> + +// CHECK: [[SAN:.*Sanitizer]]:DEADLYSIGNAL +// CHECK: ERROR: [[SAN]]: SEGV on unknown address {{0x[^ ]*}} (pc +int main(int argc, char **argv) { + int n = atoi(argv[1]); + + if (n == 1) + *((volatile int *)0x0) = __LINE__; + // CHECK1: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]] + // CHECK1: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main + + if (n == 2) + *((volatile int *)0x0) = __LINE__; + // CHECK2: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]] + // CHECK2: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main + + if (n == 3) + *((volatile int *)0x0) = __LINE__; + // CHECK3: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]] + // CHECK3: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main + + if (n == 4) + *((volatile int *)0x0) = __LINE__; + // CHECK4: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]] + // CHECK4: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main +} |