[llvm-bugs] [Bug 47015] New: TypeCheck/misaligned.cpp FAILs on SPARC

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 6 07:14:28 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47015

            Bug ID: 47015
           Summary: TypeCheck/misaligned.cpp FAILs on SPARC
           Product: compiler-rt
           Version: unspecified
          Hardware: Sun
                OS: Solaris
            Status: NEW
          Severity: normal
          Priority: P
         Component: ubsan
          Assignee: unassignedbugs at nondot.org
          Reporter: ro at gcc.gnu.org
                CC: llvm-bugs at lists.llvm.org

The TypeCheck/misaligned.cpp test FAILs on SPARC:

  UBSan-Standalone-sparc :: TestCases/TypeCheck/misaligned.cpp
  UBSan-Standalone-sparcv9 :: TestCases/TypeCheck/misaligned.cpp

The failure only affects the s1 subtest:

$ ./misaligned.cpp.tmp s1
misaligned.cpp:55:5: runtime error: store to misaligned address 0xffbfee35 for
type 'int', which requires 4 byte alignment
0xffbfee35: note: pointer points here
 00 00 00 01 02 03 04  05 00 00 05 ff bf ee ac  00 00 00 02 00 00 00 00  00 00
00 02 ff bf ee ac  ff
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior misaligned.cpp:55:5 in 
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==21427==ERROR: UndefinedBehaviorSanitizer: stack-overflow on address
0xffbfee35 (pc 0x0004fe20 bp 0xffbfee48 sp 0xffbfed30 T1)
    #0 0x4fe28 in main /var/llvm/local-sparcv9-A/misaligned.cpp:63:16
    #1 0x284f4 in _start (misaligned.cpp.tmp+0x284f4)

SUMMARY: UndefinedBehaviorSanitizer: stack-overflow
/var/llvm/local-sparcv9-A/misaligned.cpp:63:16 in main
==21427==ABORTING

and can be reproduced with the following minimal testcase:

$ cat ma.c
int main(void) {
  char c[] __attribute__((aligned(8))) = { 0, 0, 0, 0, 1, 2, 3, 4, 5 };

  int *p = (int*)&c[5];
  *p = 1;
}
$ clang -g3 -O0 -m32 -fsanitize=alignment -o ma ma.c

The test dies with SIGBUS as can be seen in truss output:

21443:      Incurred fault #5, FLTACCESS  %pc = 0x0004E128
21443:        siginfo: SIGBUS BUS_ADRALN addr=0xFFBFEE2D
21443:      Received signal #10, SIGBUS [caught]
21443:        siginfo: SIGBUS BUS_ADRALN addr=0xFFBFEE2D

Since SPARC is a strict-alignment target, the unaligned access is not only
undefefined behaviour, but actually incurs a fault.  It seems ubsan cannot
handle that.

I don't currently have access to Linux/sparc64 or other strict-alignment
targets
to check if this is a Solaris issue or a generic sparc/strict-alignment one.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200806/a759e893/attachment.html>


More information about the llvm-bugs mailing list