[LLVMbugs] [Bug 9608] New: crash generating debug with templates and partially virtual MI

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Apr 2 00:25:41 PDT 2011


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

           Summary: crash generating debug with templates and partially
                    virtual MI
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nicholas at mxc.ca
                CC: dpatel at apple.com, llvmbugs at cs.uiuc.edu


This not-so-small example triggers a new crash in debug info. Ready?

  struct Empty1 { };

  template <int i> struct TheTemplate : virtual public Empty1 { 
    struct Empty2 {}; 
    typedef const Empty2 DependentType[i]; 
    TheTemplate() {} 
  }; 

  class Test : public TheTemplate<42> { 
    Test(); 
    void method(const TheTemplate<42>::DependentType *) {} 
  }; 

  Test::Test() 
      : Empty1(), 
        TheTemplate<42>() {} 

When running "clang -cc1 -emit-llvm-only -w -g -x c++-cpp-output test.cc" under
gdb, I collected this stack trace:

clang: RecordLayoutBuilder.cpp:1689: const clang::ASTRecordLayout&
clang::ASTContext::getASTRecordLayout(const clang::RecordDecl*) const:
Assertion `D && "Cannot get layout of forward declarations!"' failed.

(gdb) bt
#0  0x00007ffff6ebea75 in raise (sig=<value optimized out>) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff6ec25c0 in abort () at abort.c:92
#2  0x00007ffff6eb7941 in __assert_fail (assertion=0x274a548 "D && \"Cannot get
layout of forward declarations!\"", file=<value optimized out>, line=1689, 
    function=0x274c780 "const clang::ASTRecordLayout&
clang::ASTContext::getASTRecordLayout(const clang::RecordDecl*) const") at
assert.c:81
#3  0x0000000001826317 in clang::ASTContext::getASTRecordLayout
(this=0x353f5a0, D=0x0) at RecordLayoutBuilder.cpp:1689
#4  0x000000000174f742 in clang::ASTContext::getTypeInfo (this=0x353f5a0,
T=0x357c650) at ASTContext.cpp:887
#5  0x0000000001150cbc in clang::ASTContext::getTypeInfo (this=0x353f5a0,
T=...)
    at
/usr/local/google/home/nlewycky/llvm/tools/clang/lib/CodeGen/../../include/clang/AST/ASTContext.h:1009
#6  0x000000000174edd8 in clang::ASTContext::getTypeInfo (this=0x353f5a0,
T=0x357f140) at ASTContext.cpp:718
#7  0x000000000117c841 in clang::ASTContext::getTypeSize (this=0x353f5a0,
T=0x357f140)
    at
/usr/local/google/home/nlewycky/llvm/tools/clang/lib/CodeGen/../../include/clang/AST/ASTContext.h:1018
#8  0x00000000011a5837 in clang::CodeGen::CGDebugInfo::CreateType
(this=0x356e130, Ty=0x357f140, Unit=...) at CGDebugInfo.cpp:1239
#9  0x00000000011a6b31 in clang::CodeGen::CGDebugInfo::CreateTypeNode
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1470
#10 0x00000000011a6642 in clang::CodeGen::CGDebugInfo::getOrCreateType
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1418
#11 0x00000000011a138b in clang::CodeGen::CGDebugInfo::CreateType
(this=0x356e130, Ty=0x357fc00, Unit=...) at CGDebugInfo.cpp:540
#12 0x00000000011a6a4f in clang::CodeGen::CGDebugInfo::CreateTypeNode
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1460
#13 0x00000000011a6642 in clang::CodeGen::CGDebugInfo::getOrCreateType
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1418
#14 0x00000000011a00d9 in clang::CodeGen::CGDebugInfo::CreatePointeeType
(this=0x356e130, PointeeTy=..., Unit=...) at CGDebugInfo.cpp:426
#15 0x00000000011a06ab in clang::CodeGen::CGDebugInfo::CreatePointerLikeType
(this=0x356e130, Tag=15, Ty=0x357fca0, PointeeTy=..., Unit=...) at
CGDebugInfo.cpp:470
#16 0x00000000011a0040 in clang::CodeGen::CGDebugInfo::CreateType
(this=0x356e130, Ty=0x357fca0, Unit=...) at CGDebugInfo.cpp:418
#17 0x00000000011a699c in clang::CodeGen::CGDebugInfo::CreateTypeNode
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1457
#18 0x00000000011a6642 in clang::CodeGen::CGDebugInfo::getOrCreateType
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1418
#19 0x00000000011a165c in clang::CodeGen::CGDebugInfo::CreateType
(this=0x356e130, Ty=0x357fd90, Unit=...) at CGDebugInfo.cpp:564
#20 0x00000000011a6ad6 in clang::CodeGen::CGDebugInfo::CreateTypeNode
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1466
#21 0x00000000011a6642 in clang::CodeGen::CGDebugInfo::getOrCreateType
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1418
#22 0x00000000011a1d12 in clang::CodeGen::CGDebugInfo::getOrCreateMethodType
(this=0x356e130, Method=0x357fdf0, Unit=...) at CGDebugInfo.cpp:643
#23 0x00000000011a21db in clang::CodeGen::CGDebugInfo::CreateCXXMemberFunction
(this=0x356e130, Method=0x357fdf0, Unit=..., RecordTy=...) at
CGDebugInfo.cpp:699
#24 0x00000000011a275a in
clang::CodeGen::CGDebugInfo::CollectCXXMemberFunctions (this=0x356e130,
RD=0x357c0f0, Unit=..., EltTys=..., RecordTy=...) at CGDebugInfo.cpp:778
#25 0x00000000011a3ae1 in clang::CodeGen::CGDebugInfo::CreateType
(this=0x356e130, Ty=0x357c180) at CGDebugInfo.cpp:976
#26 0x00000000011a54bb in clang::CodeGen::CGDebugInfo::CreateType
(this=0x356e130, Ty=0x357c180) at CGDebugInfo.cpp:1191
#27 0x00000000011a6a8a in clang::CodeGen::CGDebugInfo::CreateTypeNode
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1463
#28 0x00000000011a6642 in clang::CodeGen::CGDebugInfo::getOrCreateType
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1418
#29 0x00000000011a00d9 in clang::CodeGen::CGDebugInfo::CreatePointeeType
(this=0x356e130, PointeeTy=..., Unit=...) at CGDebugInfo.cpp:426
#30 0x00000000011a06ab in clang::CodeGen::CGDebugInfo::CreatePointerLikeType
(this=0x356e130, Tag=15, Ty=0x35812c0, PointeeTy=..., Unit=...) at
CGDebugInfo.cpp:470
#31 0x00000000011a0040 in clang::CodeGen::CGDebugInfo::CreateType
(this=0x356e130, Ty=0x35812c0, Unit=...) at CGDebugInfo.cpp:418
#32 0x00000000011a699c in clang::CodeGen::CGDebugInfo::CreateTypeNode
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1457
#33 0x00000000011a6642 in clang::CodeGen::CGDebugInfo::getOrCreateType
(this=0x356e130, Ty=..., Unit=...) at CGDebugInfo.cpp:1418
#34 0x00000000011a8adb in clang::CodeGen::CGDebugInfo::EmitDeclare
(this=0x356e130, VD=0x3581470, Tag=257, Storage=0x3588bc8, ArgNo=1,
Builder=...) at CGDebugInfo.cpp:1775
#35 0x00000000011a9db6 in clang::CodeGen::CGDebugInfo::EmitDeclareOfArgVariable
(this=0x356e130, VD=0x3581470, AI=0x3588bc8, ArgNo=1, Builder=...) at
CGDebugInfo.cpp:1959
#36 0x00000000011b7283 in clang::CodeGen::CodeGenFunction::EmitParmDecl
(this=0x7fffffffbec0, D=..., Arg=0x3588b40, ArgNo=1) at CGDecl.cpp:897
#37 0x000000000118481d in clang::CodeGen::CodeGenFunction::EmitFunctionProlog
(this=0x7fffffffbec0, FI=..., Fn=0x3586b90, Args=...) at CGCall.cpp:950
#38 0x0000000001284c4f in clang::CodeGen::CodeGenFunction::StartFunction
(this=0x7fffffffbec0, GD=..., RetTy=..., Fn=0x3586b90, FnInfo=..., Args=...,
StartLoc=...)
    at CodeGenFunction.cpp:293
#39 0x0000000001285134 in clang::CodeGen::CodeGenFunction::GenerateCode
(this=0x7fffffffbec0, GD=..., Fn=0x3586b90, FnInfo=...) at
CodeGenFunction.cpp:355
#40 0x000000000117efdf in clang::CodeGen::CodeGenModule::EmitCXXConstructor
(this=0x356d8a0, ctor=0x3580f80, ctorType=clang::Ctor_Complete) at
CGCXX.cpp:213
#41 0x000000000114ae0f in clang::CodeGen::CodeGenModule::EmitGlobalDefinition
(this=0x356d8a0, GD=...) at CodeGenModule.cpp:787
#42 0x000000000114aafb in clang::CodeGen::CodeGenModule::EmitGlobal
(this=0x356d8a0, GD=...) at CodeGenModule.cpp:741
#43 0x000000000117ee31 in clang::CodeGen::CodeGenModule::EmitCXXConstructors
(this=0x356d8a0, D=0x3580f80) at CGCXX.cpp:190
#44 0x000000000114f83b in clang::CodeGen::CodeGenModule::EmitTopLevelDecl
(this=0x356d8a0, D=0x3580f80) at CodeGenModule.cpp:2047
#45 0x000000000114474d in (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl (this=0x354e050, DG=...) at
ModuleBuilder.cpp:65
#46 0x0000000001143a0f in clang::BackendConsumer::HandleTopLevelDecl
(this=0x3544740, D=...) at CodeGenAction.cpp:86
#47 0x00000000012a34a5 in clang::ParseAST (S=..., PrintStats=false) at
ParseAST.cpp:85
#48 0x0000000001007d43 in clang::ASTFrontendAction::ExecuteAction
(this=0x3536240) at FrontendAction.cpp:376
#49 0x0000000001142f47 in clang::CodeGenAction::ExecuteAction (this=0x3536240)
at CodeGenAction.cpp:341
#50 0x0000000001007994 in clang::FrontendAction::Execute (this=0x3536240) at
FrontendAction.cpp:296
#51 0x0000000000feffa5 in clang::CompilerInstance::ExecuteAction
(this=0x35347e0, Act=...) at CompilerInstance.cpp:562
#52 0x0000000000f96d33 in clang::ExecuteCompilerInvocation (Clang=0x35347e0) at
ExecuteCompilerInvocation.cpp:153
#53 0x0000000000f88a57 in cc1_main (ArgBegin=0x7fffffffd730,
ArgEnd=0x7fffffffd760, Argv0=0x352b108
"/usr/local/google/home/nlewycky/llvm/Debug+Asserts/bin/clang", 
    MainAddr=0xf90d04) at cc1_main.cpp:158
#54 0x0000000000f924cd in main (argc_=8, argv_=0x7fffffffe778) at
driver.cpp:352
(gdb) up 8
#8  0x00000000011a5837 in clang::CodeGen::CGDebugInfo::CreateType
(this=0x356e130, Ty=0x357f140, Unit=...) at CGDebugInfo.cpp:1239
1239        Size = CGM.getContext().getTypeSize(Ty);
(gdb) p Ty
$1 = (const clang::ArrayType *) 0x357f140
(gdb) p Ty->dump()
: const struct TheTemplate<42>::Empty2 identifier[42]
$2 = void

Just to confirm, this is with a clang that has the fix to bug 9600. :)

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