Skip to content

Commit

Permalink
[sanitizer_common] Fix signal_line.cpp on SPARC (llvm#100535)
Browse files Browse the repository at this point in the history
```
  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`.
  • Loading branch information
rorth authored and banach-space committed Aug 7, 2024
1 parent 0b0bf1f commit fec5ea6
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ int main(int argc, char **argv) {
// CHECK1: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main

if (n == 2)
*((volatile int *)0x1) = __LINE__;
// Allow for strict-alignment targets that require natural alignment.
*((volatile int *)0x8) = __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
}

0 comments on commit fec5ea6

Please sign in to comment.