Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Front end crash on short (66 byte) code snippet #79745

Closed
tonyelewis opened this issue Jan 28, 2024 · 4 comments
Closed

Front end crash on short (66 byte) code snippet #79745

tonyelewis opened this issue Jan 28, 2024 · 4 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] duplicate Resolved as duplicate

Comments

@tonyelewis
Copy link

Running clang++ a.cpp with up to date build (987087df90026605fc8d03ebda5a1cd31b71e609, 2024-01-23) on:

template <typename = int> struct a;
auto f() {
	a c;
	return c;
}

(demonstrated: https://godbolt.org/z/4jv8E7ns8)

…gives:

a.cpp:3:4: error: implicit instantiation of undefined template 'a<>'
    3 |         a c;
      |           ^
a.cpp:1:34: note: template is declared here
    1 | template <typename = int> struct a;
      |                                  ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /the-llvm-dir/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name a.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/tmp -fcoverage-compilation-dir=/tmp -resource-dir /the-llvm-dir/lib/clang/19 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /the-llvm-dir/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/a-a3d6fd.o -x c++ a.cpp
1.	a.cpp:4:10: current parser token ';'
2.	a.cpp:2:10: parsing function body 'f'
3.	a.cpp:2:10: in compound statement ('{}')
 #0 0x000055ec1be34450 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/the-llvm-dir/bin/clang-19+0x37c5450)
 #1 0x000055ec1be31a1e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fc8d5e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000055ec1f08070c clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/the-llvm-dir/bin/clang-19+0x6a1170c)
 #4 0x000055ec1ec1d0c4 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x65ae0c4)
 #5 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #6 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #7 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #8 0x000055ec1ec1d729 clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/the-llvm-dir/bin/clang-19+0x65ae729)
 #9 0x000055ec1e71591c clang::Sema::getNamedReturnInfo(clang::VarDecl const*) (/the-llvm-dir/bin/clang-19+0x60a691c)
#10 0x000055ec1e7159a2 clang::Sema::getNamedReturnInfo(clang::Expr*&, clang::Sema::SimplerImplicitMoveMode) (/the-llvm-dir/bin/clang-19+0x60a69a2)
#11 0x000055ec1e73e0a4 clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) (/the-llvm-dir/bin/clang-19+0x60cf0a4)
#12 0x000055ec1e73f8c7 clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/the-llvm-dir/bin/clang-19+0x60d08c7)
#13 0x000055ec1df53718 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/the-llvm-dir/bin/clang-19+0x58e4718)
#14 0x000055ec1df546c8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/the-llvm-dir/bin/clang-19+0x58e56c8)
#15 0x000055ec1df554c1 clang::Parser::ParseCompoundStatementBody(bool) (/the-llvm-dir/bin/clang-19+0x58e64c1)
#16 0x000055ec1df5844a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/the-llvm-dir/bin/clang-19+0x58e944a)
#17 0x000055ec1de73ae6 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/the-llvm-dir/bin/clang-19+0x5804ae6)
#18 0x000055ec1dead3df clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/the-llvm-dir/bin/clang-19+0x583e3df)
#19 0x000055ec1de6e4f6 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/the-llvm-dir/bin/clang-19+0x57ff4f6)
#20 0x000055ec1de75c42 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/the-llvm-dir/bin/clang-19+0x5806c42)
#21 0x000055ec1de77627 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/the-llvm-dir/bin/clang-19+0x5808627)
#22 0x000055ec1de67d2a clang::ParseAST(clang::Sema&, bool, bool) (/the-llvm-dir/bin/clang-19+0x57f8d2a)
#23 0x000055ec1c8c6b31 clang::FrontendAction::Execute() (/the-llvm-dir/bin/clang-19+0x4257b31)
#24 0x000055ec1c8454f9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/the-llvm-dir/bin/clang-19+0x41d64f9)
#25 0x000055ec1c989113 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/the-llvm-dir/bin/clang-19+0x431a113)
#26 0x000055ec194cc833 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/the-llvm-dir/bin/clang-19+0xe5d833)
#27 0x000055ec194c4c9d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x000055ec194c88fa clang_main(int, char**, llvm::ToolContext const&) (/the-llvm-dir/bin/clang-19+0xe598fa)
#29 0x000055ec193c9e9b main (/the-llvm-dir/bin/clang-19+0xd5ae9b)
#30 0x00007fc8d5e29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007fc8d5e29e40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007fc8d5e29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x000055ec194c4115 _start (/the-llvm-dir/bin/clang-19+0xe55115)
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 19.0.0git (https://github.com/llvm/llvm-project.git 987087df90026605fc8d03ebda5a1cd31b71e609)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /the-llvm-dir/bin
clang++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/a-f4ce2e.cpp
clang++: note: diagnostic msg: /tmp/a-f4ce2e.sh
clang++: note: diagnostic msg: 

********************
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Jan 28, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 28, 2024

@llvm/issue-subscribers-clang-frontend

Author: Tony E Lewis (tonyelewis)

Running `clang++ a.cpp` with up to date build (`987087df90026605fc8d03ebda5a1cd31b71e609`, 2024-01-23) on:
template &lt;typename = int&gt; struct a;
auto f() {
	a c;
	return c;
}

(demonstrated: https://godbolt.org/z/4jv8E7ns8)

&hellip;gives:

a.cpp:3:4: error: implicit instantiation of undefined template 'a&lt;&gt;'
    3 |         a c;
      |           ^
a.cpp:1:34: note: template is declared here
    1 | template &lt;typename = int&gt; struct a;
      |                                  ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /the-llvm-dir/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name a.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/tmp -fcoverage-compilation-dir=/tmp -resource-dir /the-llvm-dir/lib/clang/19 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /the-llvm-dir/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/a-a3d6fd.o -x c++ a.cpp
1.	a.cpp:4:10: current parser token ';'
2.	a.cpp:2:10: parsing function body 'f'
3.	a.cpp:2:10: in compound statement ('{}')
 #<!-- -->0 0x000055ec1be34450 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/the-llvm-dir/bin/clang-19+0x37c5450)
 #<!-- -->1 0x000055ec1be31a1e SignalHandler(int) Signals.cpp:0:0
 #<!-- -->2 0x00007fc8d5e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->3 0x000055ec1f08070c clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/the-llvm-dir/bin/clang-19+0x6a1170c)
 #<!-- -->4 0x000055ec1ec1d0c4 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x65ae0c4)
 #<!-- -->5 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #<!-- -->6 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #<!-- -->7 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #<!-- -->8 0x000055ec1ec1d729 clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/the-llvm-dir/bin/clang-19+0x65ae729)
 #<!-- -->9 0x000055ec1e71591c clang::Sema::getNamedReturnInfo(clang::VarDecl const*) (/the-llvm-dir/bin/clang-19+0x60a691c)
#<!-- -->10 0x000055ec1e7159a2 clang::Sema::getNamedReturnInfo(clang::Expr*&amp;, clang::Sema::SimplerImplicitMoveMode) (/the-llvm-dir/bin/clang-19+0x60a69a2)
#<!-- -->11 0x000055ec1e73e0a4 clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) (/the-llvm-dir/bin/clang-19+0x60cf0a4)
#<!-- -->12 0x000055ec1e73f8c7 clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/the-llvm-dir/bin/clang-19+0x60d08c7)
#<!-- -->13 0x000055ec1df53718 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;) (/the-llvm-dir/bin/clang-19+0x58e4718)
#<!-- -->14 0x000055ec1df546c8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/the-llvm-dir/bin/clang-19+0x58e56c8)
#<!-- -->15 0x000055ec1df554c1 clang::Parser::ParseCompoundStatementBody(bool) (/the-llvm-dir/bin/clang-19+0x58e64c1)
#<!-- -->16 0x000055ec1df5844a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&amp;) (/the-llvm-dir/bin/clang-19+0x58e944a)
#<!-- -->17 0x000055ec1de73ae6 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::LateParsedAttrList*) (/the-llvm-dir/bin/clang-19+0x5804ae6)
#<!-- -->18 0x000055ec1dead3df clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/the-llvm-dir/bin/clang-19+0x583e3df)
#<!-- -->19 0x000055ec1de6e4f6 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/the-llvm-dir/bin/clang-19+0x57ff4f6)
#<!-- -->20 0x000055ec1de75c42 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/the-llvm-dir/bin/clang-19+0x5806c42)
#<!-- -->21 0x000055ec1de77627 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/the-llvm-dir/bin/clang-19+0x5808627)
#<!-- -->22 0x000055ec1de67d2a clang::ParseAST(clang::Sema&amp;, bool, bool) (/the-llvm-dir/bin/clang-19+0x57f8d2a)
#<!-- -->23 0x000055ec1c8c6b31 clang::FrontendAction::Execute() (/the-llvm-dir/bin/clang-19+0x4257b31)
#<!-- -->24 0x000055ec1c8454f9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/the-llvm-dir/bin/clang-19+0x41d64f9)
#<!-- -->25 0x000055ec1c989113 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/the-llvm-dir/bin/clang-19+0x431a113)
#<!-- -->26 0x000055ec194cc833 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/the-llvm-dir/bin/clang-19+0xe5d833)
#<!-- -->27 0x000055ec194c4c9d ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->28 0x000055ec194c88fa clang_main(int, char**, llvm::ToolContext const&amp;) (/the-llvm-dir/bin/clang-19+0xe598fa)
#<!-- -->29 0x000055ec193c9e9b main (/the-llvm-dir/bin/clang-19+0xd5ae9b)
#<!-- -->30 0x00007fc8d5e29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->31 0x00007fc8d5e29e40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->32 0x00007fc8d5e29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->33 0x000055ec194c4115 _start (/the-llvm-dir/bin/clang-19+0xe55115)
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 19.0.0git (https://github.com/llvm/llvm-project.git 987087df90026605fc8d03ebda5a1cd31b71e609)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /the-llvm-dir/bin
clang++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/a-f4ce2e.cpp
clang++: note: diagnostic msg: /tmp/a-f4ce2e.sh
clang++: note: diagnostic msg: 

********************

@AMS21
Copy link
Contributor

AMS21 commented Jan 28, 2024

Using a debug build of clang of commit 3bf21ba597d00253c6ef55bb0b499711dd778d84 it seems to hit this assertion.

Full output:

/mnt/data/dev/llvm-project/build/test.cpp:3:5: error: implicit instantiation of undefined template 'a<>'
    3 |   a c;
      |     ^
/mnt/data/dev/llvm-project/build/test.cpp:1:34: note: template is declared here
    1 | template <typename = int> struct a;
      |                                  ^
clang-19: /mnt/data/dev/llvm-project/clang/lib/AST/RecordLayoutBuilder.cpp:3335: const ASTRecordLayout &clang::ASTContext::getASTRecordLayout(const RecordDecl *) const: Assertion `D && "Cannot get layout of forward declarations!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /mnt/data/dev/llvm-project/build/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/mnt/data/dev/llvm-project -fcoverage-compilation-dir=/mnt/data/dev/llvm-project -resource-dir /mnt/data/dev/llvm-project/build/lib/clang/19 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/backward -internal-isystem /mnt/data/dev/llvm-project/build/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-8ba5d9.o -x c++ /mnt/data/dev/llvm-project/build/test.cpp
1.      /mnt/data/dev/llvm-project/build/test.cpp:4:11: current parser token ';'
2.      /mnt/data/dev/llvm-project/build/test.cpp:2:10: parsing function body 'f'
3.      /mnt/data/dev/llvm-project/build/test.cpp:2:10: in compound statement ('{}')
 #0 0x0000555560ea84a1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /mnt/data/dev/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x0000555560ea899b PrintStackTraceSignalHandler(void*) /mnt/data/dev/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x0000555560ea6996 llvm::sys::RunSignalHandlers() /mnt/data/dev/llvm-project/llvm/lib/Support/Signals.cpp:105:5
 #3 0x0000555560ea9135 SignalHandler(int) /mnt/data/dev/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007ffff785c710 (/usr/lib/libc.so.6+0x3e710)
 #5 0x00007ffff78ac83c (/usr/lib/libc.so.6+0x8e83c)
 #6 0x00007ffff785c668 gsignal (/usr/lib/libc.so.6+0x3e668)
 #7 0x00007ffff78444b8 abort (/usr/lib/libc.so.6+0x264b8)
 #8 0x00007ffff78443dc (/usr/lib/libc.so.6+0x263dc)
 #9 0x00007ffff7854d26 (/usr/lib/libc.so.6+0x36d26)
#10 0x00005555679a608d clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const /mnt/data/dev/llvm-project/clang/lib/AST/RecordLayoutBuilder.cpp:3336:3
#11 0x0000555567254df5 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const /mnt/data/dev/llvm-project/clang/lib/AST/ASTContext.cpp:2287:28
#12 0x0000555567255f45 clang::ASTContext::getTypeInfo(clang::Type const*) const /mnt/data/dev/llvm-project/clang/lib/AST/ASTContext.cpp:1866:17
#13 0x0000555567254f66 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const /mnt/data/dev/llvm-project/clang/lib/AST/ASTContext.cpp:2305:12
#14 0x0000555567255f45 clang::ASTContext::getTypeInfo(clang::Type const*) const /mnt/data/dev/llvm-project/clang/lib/AST/ASTContext.cpp:1866:17
#15 0x0000555567255150 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const /mnt/data/dev/llvm-project/clang/lib/AST/ASTContext.cpp:2339:12
#16 0x0000555567255f45 clang::ASTContext::getTypeInfo(clang::Type const*) const /mnt/data/dev/llvm-project/clang/lib/AST/ASTContext.cpp:1866:17
#17 0x000055556132028d clang::ASTContext::getTypeInfo(clang::QualType) const /mnt/data/dev/llvm-project/clang/include/clang/AST/ASTContext.h:2309:51
#18 0x0000555561c53655 clang::ASTContext::getTypeAlign(clang::QualType) const /mnt/data/dev/llvm-project/clang/include/clang/AST/ASTContext.h:2346:52
#19 0x0000555567256a79 clang::ASTContext::getTypeAlignInChars(clang::QualType) const /mnt/data/dev/llvm-project/clang/lib/AST/ASTContext.cpp:2433:30
#20 0x00005555667fe2ca clang::Sema::getNamedReturnInfo(clang::VarDecl const*) /mnt/data/dev/llvm-project/clang/lib/Sema/SemaStmt.cpp:3460:42
#21 0x00005555667fdfde clang::Sema::getNamedReturnInfo(clang::Expr*&, clang::Sema::SimplerImplicitMoveMode) /mnt/data/dev/llvm-project/clang/lib/Sema/SemaStmt.cpp:3394:25
#22 0x0000555566800c05 clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) /mnt/data/dev/llvm-project/clang/lib/Sema/SemaStmt.cpp:3955:28
#23 0x0000555566800ad4 clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) /mnt/data/dev/llvm-project/clang/lib/Sema/SemaStmt.cpp:3916:7
#24 0x000055556565ab1f clang::Parser::ParseReturnStatement() /mnt/data/dev/llvm-project/clang/lib/Parse/ParseStmt.cpp:2456:18
#25 0x0000555565653de9 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /mnt/data/dev/llvm-project/clang/lib/Parse/ParseStmt.cpp:326:11
#26 0x000055556565328b clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /mnt/data/dev/llvm-project/clang/lib/Parse/ParseStmt.cpp:118:20
#27 0x000055556565c3c2 clang::Parser::ParseCompoundStatementBody(bool) /mnt/data/dev/llvm-project/clang/lib/Parse/ParseStmt.cpp:1236:11
#28 0x000055556565dab1 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /mnt/data/dev/llvm-project/clang/lib/Parse/ParseStmt.cpp:2514:21
#29 0x0000555565587314 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /mnt/data/dev/llvm-project/clang/lib/Parse/Parser.cpp:1516:3
#30 0x000055556562ce3e clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /mnt/data/dev/llvm-project/clang/lib/Parse/ParseDecl.cpp:2272:27
#31 0x000055556558610c clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /mnt/data/dev/llvm-project/clang/lib/Parse/Parser.cpp:1244:10
#32 0x00005555655855fe clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /mnt/data/dev/llvm-project/clang/lib/Parse/Parser.cpp:1266:12
#33 0x0000555565584e80 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /mnt/data/dev/llvm-project/clang/lib/Parse/Parser.cpp:1070:14
#34 0x0000555565582cdc clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /mnt/data/dev/llvm-project/clang/lib/Parse/Parser.cpp:760:12
#35 0x000055556557da9a clang::ParseAST(clang::Sema&, bool, bool) /mnt/data/dev/llvm-project/clang/lib/Parse/ParseAST.cpp:163:16
#36 0x00005555622707cb clang::ASTFrontendAction::ExecuteAction() /mnt/data/dev/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1185:1
#37 0x0000555561d5f0e6 clang::CodeGenAction::ExecuteAction() /mnt/data/dev/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1154:5
#38 0x00005555622701ec clang::FrontendAction::Execute() /mnt/data/dev/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1073:7
#39 0x00005555621926dc clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /mnt/data/dev/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1057:23
#40 0x00005555624420b1 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /mnt/data/dev/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:272:8
#41 0x000055555d264b9f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /mnt/data/dev/llvm-project/clang/tools/driver/cc1_main.cpp:294:13
#42 0x000055555d2552a2 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /mnt/data/dev/llvm-project/clang/tools/driver/driver.cpp:365:5
#43 0x000055555d253feb clang_main(int, char**, llvm::ToolContext const&) /mnt/data/dev/llvm-project/clang/tools/driver/driver.cpp:405:5
#44 0x000055555d289045 main /mnt/data/dev/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:17:3
#45 0x00007ffff7845cd0 (/usr/lib/libc.so.6+0x27cd0)
#46 0x00007ffff7845d8a __libc_start_main (/usr/lib/libc.so.6+0x27d8a)
#47 0x000055555d253a65 _start (/mnt/data/dev/llvm-project/build/bin/clang-19+0x7cffa65)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.0.0git (https://github.com/AMS21/llvm-project.git 3bf21ba597d00253c6ef55bb0b499711dd778d84)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /mnt/data/dev/llvm-project/build/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-a4bf7e.cpp
clang: note: diagnostic msg: /tmp/test-a4bf7e.sh
clang: note: diagnostic msg: 

********************

@shafik
Copy link
Collaborator

shafik commented Jan 28, 2024

Duplicate of: #63244

Although this case looks slightly simpler.

@shafik shafik closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2024
@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label Jan 29, 2024
shafik added a commit to shafik/llvm-project that referenced this issue Jan 29, 2024
…rrors

In Sema in `BuildReturnStmt(...)` when we try to determine is the type is move
eligable or copy elidable we don't currently check of the init of the `VarDecl`
contain errors or not. This can lead to a crash since we may send a type that
is not complete into `getTypeInfo(...)` which does not allow this.

This fixes: llvm#63244
llvm#79745
shafik added a commit to shafik/llvm-project that referenced this issue Jan 29, 2024
…rrors

In Sema in `BuildReturnStmt(...)` when we try to determine is the type is move
eligable or copy elidable we don't currently check of the init of the `VarDecl`
contain errors or not. This can lead to a crash since we may send a type that
is not complete into `getTypeInfo(...)` which does not allow this.

This fixes: llvm#63244
llvm#79745
shafik added a commit to shafik/llvm-project that referenced this issue Jan 29, 2024
…rrors

In Sema in `BuildReturnStmt(...)` when we try to determine is the type is move
eligable or copy elidable we don't currently check of the init of the `VarDecl`
contain errors or not. This can lead to a crash since we may send a type that
is not complete into `getTypeInfo(...)` which does not allow this.

This fixes: llvm#63244
llvm#79745
shafik added a commit that referenced this issue Jan 29, 2024
…rrors (#79788)

In Sema in `BuildReturnStmt(...)` when we try to determine is the type
is move eligible or copy elidable we don't currently check of the init
of the `VarDecl` contain errors or not. This can lead to a crash since
we may send a type that is not complete into `getTypeInfo(...)` which
does not allow this.

This fixes: #63244
#79745
@tonyelewis
Copy link
Author

Thank you so much for very quickly fixing this (via #63244, which it duplicated).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

5 participants