[llvm-bugs] [Bug 41257] New: LTO misaligns the stack causing crashes

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 27 07:41:27 PDT 2019


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

            Bug ID: 41257
           Summary: LTO misaligns the stack causing crashes
           Product: new-bugs
           Version: 8.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: henrik at gramner.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Using LTO in combination with a lager-than-default stack alignment results in
the stack becoming misaligned, which causes crashes in code that access
stack-allocated buffers using aligned AVX load/store instructions.


Minimal sample code:

void foo(int *x);

void bar(void)
{
    int x;
    foo(&x);
}


-O3 -shared -mstack-alignment=32
  <bar>:
  48 83 ec 18       sub    rsp,0x18
  48 8d 7c 24 14    lea    rdi,[rsp+0x14]
  e8 d2 fe ff ff    call   <foo at plt> // Correct stack alignment
  48 83 c4 18       add    rsp,0x18
  c3                ret


-O3 -shared -mstack-alignment=32 -flto
  <bar>:
  50                push   rax
  48 8d 7c 24 04    lea    rdi,[rsp+0x4]
  e8 d5 fe ff ff    call   <foo at plt> // Incorrect stack alignment
  58                pop    rax
  c3                ret

-- 
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/20190327/4f0deb91/attachment-0001.html>


More information about the llvm-bugs mailing list