[llvm-bugs] [Bug 37161] New: clang-cl triggers ASTContext::getASTRecordLayout Assertion `D && "Cannot get layout of forward declarations!"'

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 18 03:17:59 PDT 2018


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

            Bug ID: 37161
           Summary: clang-cl triggers ASTContext::getASTRecordLayout
                    Assertion `D && "Cannot get layout of forward
                    declarations!"'
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stephan.bergmann.secondary at googlemail.com
                CC: llvm-bugs at lists.llvm.org

At least with recent trunk:

> $ cat test.cc
> template<typename> struct T {};
> struct B1 { virtual T<void> f() = 0; };
> struct B2 { virtual T<void> f() = 0; };
> struct S: B1, B2 { T<void> f(); };
> void f() { new S; }
> 
> $ clang -cc1 -triple x86_64-pc-windows-msvc19.0.0 -emit-obj test.cc
> clang: clang/lib/AST/RecordLayoutBuilder.cpp:2962: const clang::ASTRecordLayout& clang::ASTContext::getASTRecordLayout(const clang::RecordDecl*) const: Assertion `D && "Cannot get layout of forward declarations!"' failed.
> Stack dump:
> 0.	Program arguments: clang -cc1 -triple x86_64-pc-windows-msvc19.0.0 -emit-obj test.cc 
> 1.	<eof> parser at end of file
> 2.	Per-file LLVM IR generation
> #0 0x0000000004000f4a llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm/lib/Support/Unix/Signals.inc:398:0
> #1 0x0000000004000fdd PrintStackTraceSignalHandler(void*) llvm/lib/Support/Unix/Signals.inc:462:0
> #2 0x0000000003fff482 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:49:0
> #3 0x00000000040008bf SignalHandler(int) llvm/lib/Support/Unix/Signals.inc:252:0
> #4 0x00007fb3767861b0 __restore_rt (/lib64/libpthread.so.0+0x121b0)
> #5 0x00007fb3752ba660 __GI_raise /usr/src/debug/glibc-2.26-146-gd300041c53/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
> #6 0x00007fb3752bbc41 __GI_abort /usr/src/debug/glibc-2.26-146-gd300041c53/stdlib/abort.c:81:0
> #7 0x00007fb3752b2f7a __assert_fail_base /usr/src/debug/glibc-2.26-146-gd300041c53/assert/assert.c:89:0
> #8 0x00007fb3752b2ff2 (/lib64/libc.so.6+0x2cff2)
> #9 0x00000000070240c0 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const clang/lib/AST/RecordLayoutBuilder.cpp:2963:0
> #10 0x0000000006d87e2b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const clang/lib/AST/ASTContext.cpp:1901:0
> #11 0x0000000006d86e85 clang::ASTContext::getTypeInfo(clang::Type const*) const clang/lib/AST/ASTContext.cpp:1652:0
> #12 0x0000000006d871a3 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const clang/include/clang/AST/TypeNodes.def:99:0
> #13 0x0000000006d86e85 clang::ASTContext::getTypeInfo(clang::Type const*) const clang/lib/AST/ASTContext.cpp:1652:0
> #14 0x00000000042ebeb0 clang::ASTContext::getTypeInfo(clang::QualType) const clang/include/clang/AST/ASTContext.h:2016:0
> #15 0x0000000004578923 clang::ASTContext::getTypeAlign(clang::QualType) const clang/include/clang/AST/ASTContext.h:2043:0
> #16 0x0000000006d88527 clang::ASTContext::getTypeAlignInChars(clang::QualType) const clang/lib/AST/ASTContext.cpp:2013:0
> #17 0x000000000468a56e clang::CodeGen::CodeGenFunction::CreateIRTemp(clang::QualType, llvm::Twine const&) clang/lib/CodeGen/CGExpr.cpp:123:0
> #18 0x00000000043af7de clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) clang/lib/CodeGen/CodeGenFunction.cpp:1078:0
> #19 0x000000000439d978 clang::CodeGen::CodeGenFunction::StartThunk(llvm::Function*, clang::GlobalDecl, clang::CodeGen::CGFunctionInfo const&, bool) clang/lib/CodeGen/CGVTables.cpp:257:0
> #20 0x000000000439eb09 clang::CodeGen::CodeGenFunction::generateThunk(llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::GlobalDecl, clang::ThunkInfo const&, bool) clang/lib/CodeGen/CGVTables.cpp:433:0
> #21 0x000000000439f2d5 clang::CodeGen::CodeGenVTables::maybeEmitThunk(clang::GlobalDecl, clang::ThunkInfo const&, bool) clang/lib/CodeGen/CGVTables.cpp:561:0
> #22 0x000000000439fac3 clang::CodeGen::CodeGenVTables::addVTableComponent(clang::CodeGen::ConstantArrayBuilder&, clang::VTableLayout const&, unsigned int, llvm::Constant*, unsigned int&) clang/lib/CodeGen/CGVTables.cpp:677:0
> #23 0x000000000439fd4e clang::CodeGen::CodeGenVTables::createVTableInitializer(clang::CodeGen::ConstantStructBuilder&, clang::VTableLayout const&, llvm::Constant*) clang/lib/CodeGen/CGVTables.cpp:714:0
> #24 0x0000000004534f7f (anonymous namespace)::MicrosoftCXXABI::emitVTableDefinitions(clang::CodeGen::CodeGenVTables&, clang::CXXRecordDecl const*) clang/lib/CodeGen/MicrosoftCXXABI.cpp:1656:0
> #25 0x00000000043a0587 clang::CodeGen::CodeGenVTables::GenerateClassData(clang::CXXRecordDecl const*) clang/lib/CodeGen/CGVTables.cpp:892:0
> #26 0x00000000043a0779 clang::CodeGen::CodeGenModule::EmitDeferredVTables() clang/lib/CodeGen/CGVTables.cpp:960:0
> #27 0x00000000043ca484 clang::CodeGen::CodeGenModule::EmitDeferred() clang/lib/CodeGen/CodeGenModule.cpp:1662:0
> #28 0x00000000043ca645 clang::CodeGen::CodeGenModule::EmitDeferred() clang/lib/CodeGen/CodeGenModule.cpp:1708:0
> #29 0x00000000043c3448 clang::CodeGen::CodeGenModule::Release() clang/lib/CodeGen/CodeGenModule.cpp:393:0
> #30 0x0000000004fff067 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) clang/lib/CodeGen/ModuleBuilder.cpp:269:0
> #31 0x0000000004ff8f56 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) clang/lib/CodeGen/CodeGenAction.cpp:238:0
> #32 0x0000000005efcbfd clang::ParseAST(clang::Sema&, bool, bool) clang/lib/Parse/ParseAST.cpp:171:0
> #33 0x0000000004985e4b clang::ASTFrontendAction::ExecuteAction() clang/lib/Frontend/FrontendAction.cpp:1005:0
> #34 0x0000000004ff74f2 clang::CodeGenAction::ExecuteAction() clang/lib/CodeGen/CodeGenAction.cpp:1044:0
> #35 0x0000000004985875 clang::FrontendAction::Execute() clang/lib/Frontend/FrontendAction.cpp:908:0
> #36 0x0000000004918987 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:990:0
> #37 0x0000000004acd0f6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:255:0
> #38 0x0000000001e32681 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) clang/tools/driver/cc1_main.cpp:221:0
> #39 0x0000000001e2850d ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) clang/tools/driver/driver.cpp:311:0
> #40 0x0000000001e29178 main clang/tools/driver/driver.cpp:383:0

(resp. a following null-pointer deref crash when built without assertions).

-- 
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/20180418/8a4c0972/attachment-0001.html>


More information about the llvm-bugs mailing list