llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.39k stars 12.15k forks source link

[clang++] Segmentation fault (core dumped) #64415

Open dsokoloski opened 1 year ago

dsokoloski commented 1 year ago
0  libLLVM-3.4.so  0x00007f323e7dc122 llvm::sys::PrintStackTrace(_IO_FILE*) + 50
1  libLLVM-3.4.so  0x00007f323e7dbee4
2  libpthread.so.0 0x00007f323d79c630
3  clang           0x0000000001109a50 clang::Decl::castFromDeclContext(clang::DeclContext const*) + 0
4  clang           0x000000000086ea39
5  clang           0x00000000008bc4ae clang::CodeGen::CodeGenFunction::GetVTTParameter(clang::GlobalDecl, bool, bool) + 62
6  clang           0x00000000008bcad1 clang::CodeGen::CodeGenFunction::EmitCXXDestructorCall(clang::CXXDestructorDecl const*, clang::CXXDtorType, bool, bool, llvm::Value*) + 49
7  clang           0x00000000008cbe26 clang::CodeGen::CodeGenFunction::emitDestroy(llvm::Value*, clang::QualType, void (*)(clang::CodeGen::CodeGenFunction&, llvm::Value*, clang::QualType), bool) + 598
8  clang           0x00000000008c366f
9  clang           0x00000000008c4392 clang::CodeGen::CodeGenFunction::PopCleanupBlock(bool) + 1762
10 clang           0x00000000008c4e82 clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator) + 34
11 clang           0x00000000008c4ebe clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator, unsigned long) + 30
12 clang           0x00000000008c0e97 clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) + 231
13 clang           0x000000000084e2af clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1759
14 clang           0x00000000008a92ff clang::CodeGen::CodeGenModule::EmitCXXConstructor(clang::CXXConstructorDecl const*, clang::CXXCtorType) + 191
15 clang           0x000000000085c831 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 417
16 clang           0x000000000085f19c clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 1404
17 clang           0x000000000086eb08
18 clang           0x000000000085f8a0 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 320
19 clang           0x0000000000808213
20 clang           0x0000000000807555
21 clang           0x000000000097487f clang::ParseAST(clang::Sema&, bool, bool) + 607
22 clang           0x0000000000806bd2 clang::CodeGenAction::ExecuteAction() + 50
23 clang           0x000000000069e4f9 clang::FrontendAction::Execute() + 169
24 clang           0x000000000067cf65 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 309
25 clang           0x000000000066553a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1770
26 clang           0x000000000065f4c0 cc1_main(char const**, char const**, char const*, void*) + 1184
27 clang           0x000000000065dd0e main + 8814
28 libc.so.6       0x00007f323c58b555 __libc_start_main + 245
29 clang           0x000000000065e38f

Stack dump:

  1. Program arguments: /usr/bin/clang -cc1 -triple x86_64-redhat-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name nd-flow.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.27 -momit-leaf-frame-pointer -g -coverage-file /home/dsokoloski/netify/netify-agent-master/src/.libs/nd-flow.o -resource-dir /usr/bin/../lib/clang/3.4.2 -dependency-file .deps/nd-flow.Tpo -sys-header-deps -MP -MT nd-flow.lo -D HAVE_CONFIG_H -D _GNU_SOURCE -D ND_DATADIR="/usr/share/netifyd" -D ND_PID_FILE_NAME="/var/run/netifyd/netifyd.pid" -D ND_CONF_FILE_NAME="/etc/netifyd.conf" -D ND_PERSISTENT_STATEDIR="/etc/netifyd" -D ND_VOLATILE_STATEDIR="/var/run/netifyd" -D PIC -I . -I .. -I ../include -I ../libs/ndpi/src/include -I ../libs/inih/cpp -I /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/x86_64-redhat-linux/c++/4.8.5 -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.4.2/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -Wall -std=gnu++11 -fdeprecated-macro -fdebug-compilation-dir /home/dsokoloski/netify/netify-agent-master/src -ferror-limit 19 -fmessage-length 136 -fsanitize=address,init-order,use-after-return -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o .libs/nd-flow.o -x c++ nd-flow.cpp
  2. nd-flow.cpp:115:1: current parser token 'ndFlow'
  3. nd-flow.cpp:85:9: LLVM IR generation of declaration 'ndFlow::ndFlow'
  4. nd-flow.cpp:85:9: Generating code for declaration 'ndFlow::ndFlow' clang: error: unable to execute command: Segmentation fault (core dumped) clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 3.4.2 (tags/RELEASE_34/dot2-final) Target: x86_64-redhat-linux-gnu Thread model: posix nd-flow-3dc45c.tar.gz
dsokoloski commented 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:

  1. Program arguments: /opt/rh/llvm-toolset-7/root/usr/bin/clang-5.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name nd-flow.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /home/dsokoloski/netify/netify-agent-master/src/.libs/nd-flow.gcno -resource-dir /opt/rh/llvm-toolset-7/root/usr/lib64/clang/5.0.1 -dependency-file .deps/nd-flow.Tpo -sys-header-deps -MP -MT nd-flow.lo -D HAVE_CONFIG_H -I . -I .. -D _GNU_SOURCE -I ../include -I ../libs/ndpi/src/include -I ../libs/inih/cpp -D ND_DATADIR="/usr/share/netifyd" -D ND_PID_FILE_NAME="/var/run/netifyd/netifyd.pid" -D ND_CONF_FILE_NAME="/etc/netifyd.conf" -D ND_PERSISTENT_STATEDIR="/etc/netifyd" -D ND_VOLATILE_STATEDIR="/var/run/netifyd" -I /usr/local/include -D PIC -internal-isystem /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7 -internal-isystem /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/x86_64-redhat-linux -internal-isystem /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/backward -internal-isystem /usr/local/include -internal-isystem /opt/rh/llvm-toolset-7/root/usr/lib64/clang/5.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -Wall -std=gnu++11 -fdeprecated-macro -fdebug-compilation-dir /home/dsokoloski/netify/netify-agent-master/src -ferror-limit 19 -fmessage-length 136 -fsanitize=address -fsanitize-blacklist=/opt/rh/llvm-toolset-7/root/usr/lib64/clang/5.0.1/asan_blacklist.txt -fsanitize-address-use-after-scope -fno-assume-sane-operator-new -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o .libs/nd-flow.o -x c++ nd-flow.cpp
  2. nd-flow.cpp:115:1: current parser token 'ndFlow'
  3. nd-flow.cpp:85:9: LLVM IR generation of declaration 'ndFlow::ndFlow'
  4. nd-flow.cpp:85:9: Generating code for declaration 'ndFlow::ndFlow' clang-5.0: error: unable to execute command: Segmentation fault (core dumped) clang-5.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 5.0.1 (tags/RELEASE_501/final) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/rh/llvm-toolset-7/root/usr/bin nd-flow-6ccd4d.tar.gz
llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-codegen

EugeneZelenko commented 1 year ago

Both versions you use are very old. Could you please try 17 or main branch?

DimitryAndric commented 1 year ago

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-g5e866e411ca, 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.

DimitryAndric commented 1 year ago

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 &) {}
DimitryAndric commented 1 year ago

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
dsokoloski commented 1 year ago

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(); }