Open dsokoloski opened 1 year ago
Upgraded to clang v5.0.1:
#0 0x00007f61926186ca llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libLLVM-5.0.so+0x7916ca)
#1 0x00007f619261684e llvm::sys::RunSignalHandlers() (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libLLVM-5.0.so+0x78f84e)
#2 0x00007f61926169af (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libLLVM-5.0.so+0x78f9af)
#3 0x00007f6191c7a630 __restore_rt (/lib64/libpthread.so.0+0xf630)
#4 0x00007f618eee14d0 clang::Decl::castFromDeclContext(clang::DeclContext const*) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/../lib64/libclangAST.so.5+0x1a24d0)
#5 0x00007f61914b7c9d (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x2eec9d)
#6 0x00007f61912fdc5c clang::CodeGen::CodeGenFunction::GetVTTParameter(clang::GlobalDecl, bool, bool) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x134c5c)
#7 0x00007f61914b0939 (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x2e7939)
#8 0x00007f61912f1fce clang::CodeGen::CodeGenFunction::destroyCXXObject(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x128fce)
#9 0x00007f619132d505 clang::CodeGen::CodeGenFunction::emitDestroy(clang::CodeGen::Address, clang::QualType, void (*)(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType), bool) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x164505)
#10 0x00007f61912ffe98 (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x136e98)
#11 0x00007f6191303171 clang::CodeGen::CodeGenFunction::PopCleanupBlock(bool) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x13a171)
#12 0x00007f619130439d clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator, std::initializer_list<llvm::Value**>) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x13b39d)
#13 0x00007f6191304864 clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator, unsigned long, std::initializer_list<llvm::Value**>) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x13b864)
#14 0x00007f61912fda7d clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x134a7d)
#15 0x00007f619145e27b clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x29527b)
#16 0x00007f61912d22af clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::CXXMethodDecl const*, clang::CodeGen::StructorType) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x1092af)
#17 0x00007f61914b6983 (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x2ed983)
#18 0x00007f6191485d70 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x2bcd70)
#19 0x00007f6191486c00 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x2bdc00)
#20 0x00007f61914b7dc7 (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x2eedc7)
#21 0x00007f61914871fd clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x2be1fd)
#22 0x00007f61914d62c7 (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x30d2c7)
#23 0x00007f619144d535 (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x284535)
#24 0x00007f618e31d616 clang::ParseAST(clang::Sema&, bool, bool) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/../lib64/libclangParse.so.5+0x2f616)
#25 0x00007f6191451727 clang::CodeGenAction::ExecuteAction() (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangCodeGen.so.5+0x288727)
#26 0x00007f6190ba929e clang::FrontendAction::Execute() (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangFrontend.so.5+0xc329e)
#27 0x00007f6190b71c85 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangFrontend.so.5+0x8bc85)
#28 0x00007f61908e2fa8 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/rh/llvm-toolset-7/root/usr/bin/../lib64/libclangFrontendTool.so.5+0x4fa8)
#29 0x00000000004120c8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/rh/llvm-toolset-7/root/usr/bin/clang-5.0+0x4120c8)
#30 0x000000000040cbf9 main (/opt/rh/llvm-toolset-7/root/usr/bin/clang-5.0+0x40cbf9)
#31 0x00007f618f4c6555 __libc_start_main (/lib64/libc.so.6+0x22555)
#32 0x000000000040d665 _start (/opt/rh/llvm-toolset-7/root/usr/bin/clang-5.0+0x40d665)
Stack dump:
@llvm/issue-subscribers-clang-codegen
Both versions you use are very old. Could you please try 17 or main
branch?
This is an interesting case. It indeed crashes with a segfault, with older versions of clang. Then, it seems to disappear with llvmorg-10-init-07264-g
5e866e411ca, but that commit only "Bumps GNUC, __GNUC_MINOR__ from 4.2.1" (#42162)...
If you then preprocess the test case with an old version of clang, and compile it with very recent main, you still get a segfault, in clang::CodeGen::CodeGenFunction::destroyCXXObject
. So I will be taking some time to reduce this test case.
Reduced:
// clang -cc1 -triple x86_64-- -S -fexceptions nd-flow-min.cpp
struct basic_string {
basic_string();
~basic_string();
} typedef string;
struct vector {
void resize();
};
struct ndAddr {
string cached_addr;
};
vector digest_mdata;
struct ndFlow {
union {
struct {
ndAddr upper_addr;
} gtp;
};
ndFlow();
ndFlow(const ndFlow &);
~ndFlow();
};
ndFlow::ndFlow() : gtp{} { digest_mdata.resize(); }
ndFlow::ndFlow(const ndFlow &) {}
Backtrace with debug info:
Program received signal SIGSEGV, Segmentation fault.
Address not mapped to object.
clang::FunctionDecl::isTrivial (this=0x0) at /home/dim/src/llvm/llvm-project/clang/include/clang/AST/Decl.h:2274
2274 bool isTrivial() const { return FunctionDeclBits.IsTrivial; }
(gdb) bt
#0 clang::FunctionDecl::isTrivial (this=0x0) at /home/dim/src/llvm/llvm-project/clang/include/clang/AST/Decl.h:2274
#1 0x0000000006193c28 in clang::CodeGen::CodeGenFunction::destroyCXXObject (CGF=..., addr=..., type=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGClass.cpp:2103
#2 0x0000000006346870 in clang::CodeGen::CodeGenFunction::emitDestroy (this=0x7fffffff81b8, addr=..., type=..., destroyer=0x6193bd0 <clang::CodeGen::CodeGenFunction::destroyCXXObject(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType)>, useEHCleanupForArray=false) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGDecl.cpp:2252
#3 0x000000000634a626 in (anonymous namespace)::DestroyObject::Emit (this=0x7fffffff7848, CGF=..., flags=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGDecl.cpp:514
#4 0x00000000064039df in EmitCleanup (CGF=..., Fn=0x7fffffff7848, flags=..., ActiveFlag=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGCleanup.cpp:587
#5 0x0000000006402fa0 in clang::CodeGen::CodeGenFunction::PopCleanupBlock (this=0x7fffffff81b8, FallthroughIsBranchThrough=false) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGCleanup.cpp:1042
#6 0x000000000640156f in clang::CodeGen::CodeGenFunction::PopCleanupBlocks (this=0x7fffffff81b8, Old=..., ValuesToReload=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGCleanup.cpp:448
#7 0x00000000064030d3 in clang::CodeGen::CodeGenFunction::PopCleanupBlocks (this=0x7fffffff81b8, Old=..., OldLifetimeExtendedSize=0, ValuesToReload=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGCleanup.cpp:491
#8 0x00000000061a262e in clang::CodeGen::CodeGenFunction::RunCleanupsScope::ForceCleanup (this=0x7fffffff7d50, ValuesToReload=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CodeGenFunction.h:926
#9 0x00000000061905a9 in clang::CodeGen::CodeGenFunction::EmitConstructorBody (this=0x7fffffff81b8, Args=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGClass.cpp:878
#10 0x00000000061b9e63 in clang::CodeGen::CodeGenFunction::GenerateCode (this=0x7fffffff81b8, GD=..., Fn=0x80dcf4108, FnInfo=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1453
#11 0x000000000653cc21 in clang::CodeGen::CodeGenModule::codegenCXXStructor (this=0x80dd6b000, GD=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGCXX.cpp:209
#12 0x00000000068b08f2 in (anonymous namespace)::ItaniumCXXABI::emitCXXStructor (this=0x80dc23a80, GD=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/ItaniumCXXABI.cpp:4446
#13 0x0000000005ed13fa in clang::CodeGen::CodeGenModule::EmitGlobalDefinition (this=0x80dd6b000, GD=..., GV=0x0) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3898
#14 0x0000000005ed6b5e in clang::CodeGen::CodeGenModule::EmitGlobal (this=0x80dd6b000, GD=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3652
#15 0x00000000068ab934 in (anonymous namespace)::ItaniumCXXABI::EmitCXXConstructors (this=0x80dc23a80, D=0x80ddffb68) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/ItaniumCXXABI.cpp:1663
#16 0x0000000005ed019c in clang::CodeGen::CodeGenModule::EmitTopLevelDecl (this=0x80dd6b000, D=0x80ddffb68) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:6647
#17 0x00000000070a572d in (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl (this=0x80dcb4240, DG=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:190
#18 0x000000000709c770 in clang::BackendConsumer::HandleTopLevelDecl (this=0x80dc1b600, D=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:235
#19 0x000000000a18128a in clang::ParseAST (S=..., PrintStats=false, SkipFunctionBodies=false) at /home/dim/src/llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:167
#20 0x0000000006ebd2e6 in clang::ASTFrontendAction::ExecuteAction (this=0x80dc23380) at /home/dim/src/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1173
#21 0x0000000007098aa6 in clang::CodeGenAction::ExecuteAction (this=0x80dc23380) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1207
#22 0x0000000006ebcd0c in clang::FrontendAction::Execute (this=0x80dc23380) at /home/dim/src/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1063
#23 0x0000000006de87b8 in clang::CompilerInstance::ExecuteAction (this=0x80dcfc000, Act=...) at /home/dim/src/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1053
#24 0x0000000007087ec7 in clang::ExecuteCompilerInvocation (Clang=0x80dcfc000) at /home/dim/src/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:272
#25 0x0000000003d8c743 in cc1_main (Argv=..., Argv0=0x7fffffffe870 "/home/dim/obj/llvmorg-18-init-1259-g400fde929635-freebsd13-amd64-ninja-clang-dbg-1/bin/clang", MainAddr=0x3d7b570 <GetExecutablePath(char const*, bool)>) at /home/dim/src/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:249
#26 0x0000000003d7cca2 in ExecuteCC1Tool (ArgV=..., ToolContext=...) at /home/dim/src/llvm/llvm-project/clang/tools/driver/driver.cpp:366
#27 0x0000000003d7ba44 in clang_main (Argc=7, Argv=0x7fffffffe4e8, ToolContext=...) at /home/dim/src/llvm/llvm-project/clang/tools/driver/driver.cpp:407
#28 0x0000000003dacbed in main (argc=7, argv=0x7fffffffe4e8) at /home/dim/obj/llvmorg-18-init-1259-g400fde929635-freebsd13-amd64-ninja-clang-dbg-1/tools/clang/tools/driver/clang-driver.cpp:15
Looks like the dtor
variable in destroyCXXObject
is null:
(gdb) up
#1 0x0000000006193c28 in clang::CodeGen::CodeGenFunction::destroyCXXObject (CGF=..., addr=..., type=...) at /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGClass.cpp:2103
2102 const CXXDestructorDecl *dtor = record->getDestructor();
2103 assert(!dtor->isTrivial());
(gdb) p dtor
$1 = (const clang::CXXDestructorDecl *) 0x0
I recently discovered that removing the union surrounding struct gtp
prevents the fault.
// clang -cc1 -triple x86_64-- -S -fexceptions nd-flow-fix.cpp
struct basic_string {
basic_string();
~basic_string();
} typedef string;
struct vector {
void resize();
};
struct ndAddr {
string cached_addr;
};
vector digest_mdata;
struct ndFlow {
struct {
ndAddr upper_addr;
} gtp;
ndFlow();
ndFlow(const ndFlow &);
~ndFlow();
};
ndFlow::ndFlow() : gtp{} { digest_mdata.resize(); }
Stack dump: