[llvm-bugs] [Bug 48533] New: builtin longjmp miscompiled when jmpbuf is rbp-relative address

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 16 07:24:49 PST 2020


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

            Bug ID: 48533
           Summary: builtin longjmp miscompiled when jmpbuf is
                    rbp-relative address
           Product: new-bugs
           Version: 10.0
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: jfc at mit.edu
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 24293
  --> https://bugs.llvm.org/attachment.cgi?id=24293&action=edit
bitcode that llc miscompiles

If the address argument to __builtin_longjmp is %rbp-relative the longjmp is
miscompiled.  If I compile the attached .ll file with the 10.0 llc the function
ends

        movq    -48(%rbp), %rbp
        movq    -40(%rbp), %rax # This load needs the original rbp
        movq    -32(%rbp), %rsp # This load needs the original rbp
        jmpq    *%rax

Note that the first instruction overwrites %rbp but the next two instructions
depend on the old value.  The branch goes to a random address with a random
%rsp.

The same bug is present in the version of llvm 11 included with FreeBSD-CURRENT
(13.0).

-- 
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/20201216/8085f289/attachment.html>


More information about the llvm-bugs mailing list