Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94394ca

Browse files
authored
[sanitizer_common] Fix signal_line.cpp on SPARC (llvm#100535)
``` SanitizerCommon-ubsan-sparc-Linux :: Linux/signal_line.cpp ``` currently `FAIL`s on Linux/sparc64 (32 and 64-bit) for `n == 2`. Instead of the expected `SIGSEGV`, the test dies with `SIGBUS`. `strace` reveals that this is due to a unaligned access: ``` --- SIGBUS {si_signo=SIGBUS, si_code=BUS_ADRALN, si_addr=0x1} --- ``` which is to be expected on a strict-alignment target like SPARC. Fixed by changing the invalid pointer to be better aligned. Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.
1 parent 1c53b90 commit 94394ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler-rt/test/sanitizer_common/TestCases/Linux/signal_line.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ int main(int argc, char **argv) {
2020
// CHECK1: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main
2121

2222
if (n == 2)
23-
*((volatile int *)0x1) = __LINE__;
23+
// Allow for strict-alignment targets that require natural alignment.
24+
*((volatile int *)0x8) = __LINE__;
2425
// CHECK2: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]]
2526
// CHECK2: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main
2627
}

0 commit comments

Comments
 (0)