<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - TypeCheck/misaligned.cpp FAILs on SPARC"
   href="https://bugs.llvm.org/show_bug.cgi?id=47015">47015</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>TypeCheck/misaligned.cpp FAILs on SPARC
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Sun
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Solaris
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ubsan
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ro@gcc.gnu.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>