[LLVMbugs] [Bug 5358] New: llc -tailcallopt generates segfaulting code

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Oct 31 06:57:08 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=5358

           Summary: llc -tailcallopt generates segfaulting code
           Product: new-bugs
           Version: 2.5
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: buether at isp.uni-luebeck.de
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=3730)
 --> (http://llvm.org/bugs/attachment.cgi?id=3730)
Program to reproduce failure

Hello everyone,

we discovered a strange behaviour of llc when generating tail call optimised
code.
The attached program, when compiled with llvm-as, llc -tailcallopt, gcc
produces an executable, that, when run segfaults.

The source contains 3 functions:
The function main allocates a bit of memory and casts it to [0 x i32]*. This
could probably be replaced by a simpler instruction that yields an array
pointer.
It then calls ip with a bunch of parameters, some of them the freshly made
pointer.
Ip in turn just passes its parameter list on to gip, via a fast call.
Gip simply returns one.

When run, the program crashes when it tries to return from gip, because the
call frame on the stack is corrupt. It seems to get lost somewhere in ip.

The assembler code contained quite many confusing stack movements within the
ip-function. Also, the very first instruction is "subl $8, %esp", from which on
gdb is not able to detect a correct stack frame anymore.

This corruption seems to be very sensitive to the parameter list: If the
parameters are changed (e.g. ip does not forward m as m, but passes n in its
place), their types are changed, or they are removed, the program compiles and
executes correctly. Also, if compiled without -tailcallopt, the bug does not
arise.

The code is compiled for Linux 2.6.22.19-0.3-default i686 athlon i386
GNU/Linux. The GCC version is 4.2.1, the LLVM version is 2.5.

Thanks for your help,
Florian B├╝ther


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list