[LLVMbugs] [Bug 2489] New: clang -g segfaults on functions with arguments

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Jun 25 01:56:17 PDT 2008


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

           Summary: clang -g segfaults on functions with arguments
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: matthijs at stdin.nl
                CC: llvmbugs at cs.uiuc.edu


It seems that clang debug output (clang -g) breaks on any function that has
arguments.

The problem is easily illustrated using the following trivial foo.c:

  void foo(int blaa) { }

kooijman at eris:~/src/montiumccfe$ gdb --args clang -g -emit-llvm foo.c 
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1211607360 (LWP 19210)]
0x083c4765 in clang::CodeGen::CGDebugInfo::EmitDeclare (this=0x8773d00,
decl=0x8768330, Tag=257, AI=0x877891c, Builder=@0xbfb25ab8) at
CGDebugInfo.cpp:730
730       Variable->setContext(RegionStack.back());
(gdb) bt
#0  0x083c4765 in clang::CodeGen::CGDebugInfo::EmitDeclare (this=0x8773d00,
decl=0x8768330, Tag=257, AI=0x877891c, Builder=@0xbfb25ab8) at
CGDebugInfo.cpp:730
#1  0x083de65a in clang::CodeGen::CodeGenFunction::EmitParmDecl
(this=0xbfb25ab0, D=@0x8768330, Arg=0x87788a8) at CGDecl.cpp:229
#2  0x083dd07a in clang::CodeGen::CodeGenFunction::GenerateCode
(this=0xbfb25ab0, FD=0x8770e88) at CodeGenFunction.cpp:123
#3  0x083b1f07 in clang::CodeGen::CodeGenModule::EmitFunction (this=0x8771938,
FD=0x8770e88) at CodeGenModule.cpp:525
#4  0x083add62 in (anonymous namespace)::CodeGenerator::HandleTopLevelDecl
(this=0x8768b18, D=0x8770e88) at ModuleBuilder.cpp:69
#5  0x0846dc81 in clang::ParseAST (PP=@0x8756f98, Consumer=0x8768b18,
PrintStats=false) at ParseAST.cpp:63
#6  0x083a1572 in ProcessInputFile (PP=@0x8756f98, PPF=@0xbfb261c0,
InFile=@0x8756638) at clang.cpp:1305
#7  0x083a1f7b in main (argc=Cannot access memory at address 0xfffffffc
) at clang.cpp:1527
(gdb) p RegionStack.size()
$1 = 0

It seems that the declarations for the parameters are emitted before the
function start is emitted, since RegionStack is still empty (which causes the
problem). This can probably be fixed by emitting debug info for the parameter
declarations just after emitting the function start, instead of in
EmitParmDecl.


-- 
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