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

[clang ...14-15-17] Segmentation fault when using typeof({return x}) as Block Literal Expression return type #77754

Open
d4wae89d498 opened this issue Jan 11, 2024 · 2 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@d4wae89d498
Copy link

d4wae89d498 commented Jan 11, 2024

The following code do cause a segfault on clang.

int main()
{
	^typeof({ return 4; }) (int x){ return x; };

	return 0;
}
Clang 14 dump from MacOS cc test.c clang: error: unable to execute command: Segmentation fault: 11 clang: error: clang frontend command failed due to signal (use -v to see invocation) Apple clang version 14.0.0 (clang-1400.0.29.202) Target: x86_64-apple-darwin22.3.0 Thread model: posix InstalledDir: /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/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: /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-28c338.c
clang: note: diagnostic msg: /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-28c338.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/xxxx/Library/Logs/DiagnosticReports/clang__.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:


cc -v test.c
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx13.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -funwind-tables=2 -target-sdk-version=13.1 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 820.1 -v -resource-dir /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0 -isysroot /Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/usr/local/include -internal-isystem /Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include -internal-externc-isystem /Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdebug-compilation-dir=/Users/xxx/Desktop/c-with-class -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-35d470.o -x c test.c
clang -cc1 version 14.0.0 (clang-1400.0.29.202) default target x86_64-apple-darwin22.3.0
ignoring nonexistent directory "/Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include
/Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/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: /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-6480a1.c
clang: note: diagnostic msg: /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-6480a1.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/xxx/Library/Logs/DiagnosticReports/clang__.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:


Clang 15 dump from Linux 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: /usr/lib/llvm-15/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -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 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/ubuntu -resource-dir /usr/lib/llvm-15/lib/clang/15.0.7 -internal-isystem /usr/lib/llvm-15/lib/clang/15.0.7/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../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 -fdebug-compilation-dir=/home/ubuntu -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-f3b56b.o -x c test.c 1. test.c:3:20: current parser token ';' 2. test.c:2:1: parsing function body 'main' 3. test.c:2:1: in compound statement ('{}') 4. test.c:3:2: block literal parsing 5. test.c:3:10: in compound statement ('{}') #0 0x00007f04d6f54481 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf54481) #1 0x00007f04d6f5219e llvm::sys::RunSignalHandlers() (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf5219e) #2 0x00007f04d6f549a6 (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf549a6) #3 0x00007f04d583c460 (/lib/x86_64-linux-gnu/libc.so.6+0x3c460) #4 0x00007f04de975442 clang::Sema::ActOnCapScopeReturnStmt(clang::SourceLocation, clang::Expr*, clang::Sema::NamedReturnInfo&, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1775442) #5 0x00007f04de9764ea clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x17764ea) #6 0x00007f04de97631e clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x177631e) #7 0x00007f04ddd6606b clang::Parser::ParseReturnStatement() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb6606b) #8 0x00007f04ddd5fe6d clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb5fe6d) #9 0x00007f04ddd5f24f clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb5f24f) #10 0x00007f04ddd67f20 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb67f20) #11 0x00007f04ddd626dc clang::Parser::ParseCompoundStatement(bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb626dc) #12 0x00007f04ddd09aa2 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr&, clang::SourceLocation&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb09aa2) #13 0x00007f04ddd0e7d5 clang::Parser::ParseExprAfterUnaryExprOrTypeTrait(clang::Token const&, bool&, clang::OpaquePtr&, clang::SourceRange&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb0e7d5) #14 0x00007f04ddcdd7f2 clang::Parser::ParseTypeofSpecifier(clang::DeclSpec&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xadd7f2) #15 0x00007f04ddcd3266 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xad3266) #16 0x00007f04ddcc53c6 clang::Parser::ParseSpecifierQualifierList(clang::DeclSpec&, clang::AccessSpecifier, clang::Parser::DeclSpecContext) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xac53c6) #17 0x00007f04ddd0f9c6 clang::Parser::ParseBlockId(clang::SourceLocation) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb0f9c6) #18 0x00007f04ddd0dfda clang::Parser::ParseBlockLiteralExpression() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb0dfda) #19 0x00007f04ddd0703a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb0703a) #20 0x00007f04ddd02321 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb02321) #21 0x00007f04ddd02229 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb02229) #22 0x00007f04ddd616b6 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb616b6) #23 0x00007f04ddd60fd8 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb60fd8) #24 0x00007f04ddd5f24f clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb5f24f) #25 0x00007f04ddd67f20 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb67f20) #26 0x00007f04ddd68f55 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb68f55) #27 0x00007f04ddd83152 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb83152) #28 0x00007f04ddcd79e8 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xad79e8) #29 0x00007f04ddd8217a clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb8217a) #30 0x00007f04ddd81bd7 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb81bd7) #31 0x00007f04ddd80efa clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb80efa) #32 0x00007f04ddd7f1c3 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb7f1c3) #33 0x00007f04ddd7ec8f clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb7ec8f) #34 0x00007f04ddcbd9d6 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xabd9d6) #35 0x00007f04deeb0a15 clang::CodeGenAction::ExecuteAction() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1cb0a15) #36 0x00007f04df8eebb7 clang::FrontendAction::Execute() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x26eebb7) #37 0x00007f04df85fd06 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x265fd06) #38 0x00007f04df96d16a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x276d16a) #39 0x0000562c6a016188 cc1_main(llvm::ArrayRef, char const*, void*) (/usr/lib/llvm-15/bin/clang+0x14188) #40 0x0000562c6a01428b (/usr/lib/llvm-15/bin/clang+0x1228b) #41 0x0000562c6a0140e2 clang_main(int, char**) (/usr/lib/llvm-15/bin/clang+0x120e2) #42 0x00007f04d5823a90 (/lib/x86_64-linux-gnu/libc.so.6+0x23a90) #43 0x00007f04d5823b49 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23b49) #44 0x0000562c6a010ed5 _start (/usr/lib/llvm-15/bin/clang+0xeed5) clang: error: unable to execute command: Segmentation fault (core dumped) clang: error: clang frontend command failed due to signal (use -v to see invocation) Ubuntu clang version 15.0.7 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/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-696c38.c
clang: note: diagnostic msg: /tmp/test-696c38.sh
clang: note: diagnostic msg:

Clang 17 dump from Linux
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: /usr/lib/llvm-17/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -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 -fcoverage-compilation-dir=/home/ubuntu -resource-dir /usr/lib/llvm-17/lib/clang/17 -internal-isystem /usr/lib/llvm-17/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../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 -fdebug-compilation-dir=/home/ubuntu -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-c92739.o -x c test.c
1.	test.c:3:20: current parser token ';'
2.	test.c:2:1: parsing function body 'main'
3.	test.c:2:1: in compound statement ('{}')
4.	test.c:3:2: block literal parsing
5.	test.c:3:10: in compound statement ('{}')
 #0 0x00007f19acacf126 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xccf126)
 #1 0x00007f19acacd360 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xccd360)
 #2 0x00007f19acacf7bb (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xccf7bb)
 #3 0x00007f19ab63c460 (/lib/x86_64-linux-gnu/libc.so.6+0x3c460)
 #4 0x00007f19b4de4238 clang::Sema::ActOnCapScopeReturnStmt(clang::SourceLocation, clang::Expr*, clang::Sema::NamedReturnInfo&, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x17e4238)
 #5 0x00007f19b4de5598 clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x17e5598)
 #6 0x00007f19b4de53ce clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x17e53ce)
 #7 0x00007f19b40e3fe6 clang::Parser::ParseReturnStatement() (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae3fe6)
 #8 0x00007f19b40de5aa clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xade5aa)
 #9 0x00007f19b40dd9a8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xadd9a8)
#10 0x00007f19b40e5e00 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae5e00)
#11 0x00007f19b40e084d clang::Parser::ParseCompoundStatement(bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae084d)
#12 0x00007f19b4086c9d clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa86c9d)
#13 0x00007f19b408b8f1 clang::Parser::ParseExprAfterUnaryExprOrTypeTrait(clang::Token const&, bool&, clang::OpaquePtr<clang::QualType>&, clang::SourceRange&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa8b8f1)
#14 0x00007f19b4059901 clang::Parser::ParseTypeofSpecifier(clang::DeclSpec&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa59901)
#15 0x00007f19b4052321 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa52321)
#16 0x00007f19b40507b2 clang::Parser::ParseSpecifierQualifierList(clang::DeclSpec&, clang::ImplicitTypenameContext, clang::AccessSpecifier, clang::Parser::DeclSpecContext) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa507b2)
#17 0x00007f19b408cc83 clang::Parser::ParseBlockId(clang::SourceLocation) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa8cc83)
#18 0x00007f19b408b1a3 clang::Parser::ParseBlockLiteralExpression() (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa8b1a3)
#19 0x00007f19b4084bf8 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa84bf8)
#20 0x00007f19b407f341 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa7f341)
#21 0x00007f19b407f219 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa7f219)
#22 0x00007f19b40dfaf5 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xadfaf5)
#23 0x00007f19b40ddff4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xaddff4)
#24 0x00007f19b40dd9a8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xadd9a8)
#25 0x00007f19b40e5e00 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae5e00)
#26 0x00007f19b40e6eaf clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae6eaf)
#27 0x00007f19b4101503 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xb01503)
#28 0x00007f19b404e420 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa4e420)
#29 0x00007f19b41005a7 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xb005a7)
#30 0x00007f19b40fffa1 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xafffa1)
#31 0x00007f19b40ff243 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xaff243)
#32 0x00007f19b40fd6e9 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xafd6e9)
#33 0x00007f19b40fd06f clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xafd06f)
#34 0x00007f19b4039606 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa39606)
#35 0x00007f19b5d55ea5 clang::FrontendAction::Execute() (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x2755ea5)
#36 0x00007f19b5ccef94 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x26cef94)
#37 0x00007f19b5dd0074 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x27d0074)
#38 0x0000557d1805c918 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-17/bin/clang+0x12918)
#39 0x0000557d1805a415 (/usr/lib/llvm-17/bin/clang+0x10415)
#40 0x0000557d180595b6 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-17/bin/clang+0xf5b6)
#41 0x0000557d18066912 main (/usr/lib/llvm-17/bin/clang+0x1c912)
#42 0x00007f19ab623a90 (/lib/x86_64-linux-gnu/libc.so.6+0x23a90)
#43 0x00007f19ab623b49 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23b49)
#44 0x0000557d18056de5 _start (/usr/lib/llvm-17/bin/clang+0xcde5)
clang-17: error: unable to execute command: Segmentation fault (core dumped)
clang-17: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 17.0.6 (++20231208085911+6009708b4367-1~exp1~20231208090013.78)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-17: note: diagnostic msg:
********************

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

********************
@github-actions github-actions bot added the clang Clang issues not falling into any other category label Jan 11, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels Jan 11, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 11, 2024

@llvm/issue-subscribers-clang-frontend

Author: None (d4wae89d498)

The following code do cause a segfault on clang.
int main()
{
	^typeof({ return 4; }) (int x){ return x; };

	return 0;
}

<details>
<summary>Clang 14 dump from MacOS </summary>
cc test.c
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/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: /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-28c338.c
clang: note: diagnostic msg: /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-28c338.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/xxxx/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:


cc -v test.c
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx13.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -funwind-tables=2 -target-sdk-version=13.1 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 820.1 -v -resource-dir /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0 -isysroot /Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/usr/local/include -internal-isystem /Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include -internal-externc-isystem /Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdebug-compilation-dir=/Users/xxx/Desktop/c-with-class -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-35d470.o -x c test.c
clang -cc1 version 14.0.0 (clang-1400.0.29.202) default target x86_64-apple-darwin22.3.0
ignoring nonexistent directory "/Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include
/Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Volumes/DATA/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Volumes/DATA/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/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: /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-6480a1.c
clang: note: diagnostic msg: /var/folders/9n/8gxzr2d15ll6h880dgb9ywvr0000gn/T/test-6480a1.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/xxx/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:


</details>

<details>
<summary>Clang 15 dump from Linux </summary>
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: /usr/lib/llvm-15/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -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 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/ubuntu -resource-dir /usr/lib/llvm-15/lib/clang/15.0.7 -internal-isystem /usr/lib/llvm-15/lib/clang/15.0.7/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../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 -fdebug-compilation-dir=/home/ubuntu -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-f3b56b.o -x c test.c

  1. test.c:3:20: current parser token ';'
  2. test.c:2:1: parsing function body 'main'
  3. test.c:2:1: in compound statement ('{}')
  4. test.c:3:2: block literal parsing
  5. test.c:3:10: in compound statement ('{}')
    #0 0x00007f04d6f54481 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf54481)
    #1 0x00007f04d6f5219e llvm::sys::RunSignalHandlers() (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf5219e)
    #2 0x00007f04d6f549a6 (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf549a6)
    #3 0x00007f04d583c460 (/lib/x86_64-linux-gnu/libc.so.6+0x3c460)
    #4 0x00007f04de975442 clang::Sema::ActOnCapScopeReturnStmt(clang::SourceLocation, clang::Expr*, clang::Sema::NamedReturnInfo&, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1775442)
    #5 0x00007f04de9764ea clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x17764ea)
    #6 0x00007f04de97631e clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x177631e)
    #7 0x00007f04ddd6606b clang::Parser::ParseReturnStatement() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb6606b)
    #8 0x00007f04ddd5fe6d clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb5fe6d)
    #9 0x00007f04ddd5f24f clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb5f24f)
    #10 0x00007f04ddd67f20 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb67f20)
    #11 0x00007f04ddd626dc clang::Parser::ParseCompoundStatement(bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb626dc)
    #12 0x00007f04ddd09aa2 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb09aa2)
    #13 0x00007f04ddd0e7d5 clang::Parser::ParseExprAfterUnaryExprOrTypeTrait(clang::Token const&, bool&, clang::OpaquePtr<clang::QualType>&, clang::SourceRange&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb0e7d5)
    #14 0x00007f04ddcdd7f2 clang::Parser::ParseTypeofSpecifier(clang::DeclSpec&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xadd7f2)
    #15 0x00007f04ddcd3266 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xad3266)
    #16 0x00007f04ddcc53c6 clang::Parser::ParseSpecifierQualifierList(clang::DeclSpec&, clang::AccessSpecifier, clang::Parser::DeclSpecContext) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xac53c6)
    #17 0x00007f04ddd0f9c6 clang::Parser::ParseBlockId(clang::SourceLocation) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb0f9c6)
    #18 0x00007f04ddd0dfda clang::Parser::ParseBlockLiteralExpression() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb0dfda)
    #19 0x00007f04ddd0703a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb0703a)
    #20 0x00007f04ddd02321 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb02321)
    #21 0x00007f04ddd02229 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb02229)
    #22 0x00007f04ddd616b6 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb616b6)
    #23 0x00007f04ddd60fd8 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb60fd8)
    #24 0x00007f04ddd5f24f clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb5f24f)
    #25 0x00007f04ddd67f20 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb67f20)
    #26 0x00007f04ddd68f55 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb68f55)
    #27 0x00007f04ddd83152 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb83152)
    #28 0x00007f04ddcd79e8 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xad79e8)
    #29 0x00007f04ddd8217a clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb8217a)
    #30 0x00007f04ddd81bd7 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb81bd7)
    #31 0x00007f04ddd80efa clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb80efa)
    #32 0x00007f04ddd7f1c3 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb7f1c3)
    #33 0x00007f04ddd7ec8f clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xb7ec8f)
    #34 0x00007f04ddcbd9d6 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0xabd9d6)
    #35 0x00007f04deeb0a15 clang::CodeGenAction::ExecuteAction() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x1cb0a15)
    #36 0x00007f04df8eebb7 clang::FrontendAction::Execute() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x26eebb7)
    #37 0x00007f04df85fd06 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x265fd06)
    #38 0x00007f04df96d16a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x276d16a)
    #39 0x0000562c6a016188 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-15/bin/clang+0x14188)
    #40 0x0000562c6a01428b (/usr/lib/llvm-15/bin/clang+0x1228b)
    #41 0x0000562c6a0140e2 clang_main(int, char**) (/usr/lib/llvm-15/bin/clang+0x120e2)
    #42 0x00007f04d5823a90 (/lib/x86_64-linux-gnu/libc.so.6+0x23a90)
    #43 0x00007f04d5823b49 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23b49)
    #44 0x0000562c6a010ed5 _start (/usr/lib/llvm-15/bin/clang+0xeed5)
    clang: error: unable to execute command: Segmentation fault (core dumped)
    clang: error: clang frontend command failed due to signal (use -v to see invocation)
    Ubuntu clang version 15.0.7
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    InstalledDir: /usr/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-696c38.c
clang: note: diagnostic msg: /tmp/test-696c38.sh
clang: note: diagnostic msg:
</details>

<details>

<summary>Clang 17 dump from Linux </summary>

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: /usr/lib/llvm-17/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -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 -fcoverage-compilation-dir=/home/ubuntu -resource-dir /usr/lib/llvm-17/lib/clang/17 -internal-isystem /usr/lib/llvm-17/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../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 -fdebug-compilation-dir=/home/ubuntu -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-c92739.o -x c test.c
1.	test.c:3:20: current parser token ';'
2.	test.c:2:1: parsing function body 'main'
3.	test.c:2:1: in compound statement ('{}')
4.	test.c:3:2: block literal parsing
5.	test.c:3:10: in compound statement ('{}')
 #<!-- -->0 0x00007f19acacf126 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xccf126)
 #<!-- -->1 0x00007f19acacd360 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xccd360)
 #<!-- -->2 0x00007f19acacf7bb (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xccf7bb)
 #<!-- -->3 0x00007f19ab63c460 (/lib/x86_64-linux-gnu/libc.so.6+0x3c460)
 #<!-- -->4 0x00007f19b4de4238 clang::Sema::ActOnCapScopeReturnStmt(clang::SourceLocation, clang::Expr*, clang::Sema::NamedReturnInfo&amp;, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x17e4238)
 #<!-- -->5 0x00007f19b4de5598 clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x17e5598)
 #<!-- -->6 0x00007f19b4de53ce clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x17e53ce)
 #<!-- -->7 0x00007f19b40e3fe6 clang::Parser::ParseReturnStatement() (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae3fe6)
 #<!-- -->8 0x00007f19b40de5aa clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xade5aa)
 #<!-- -->9 0x00007f19b40dd9a8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xadd9a8)
#<!-- -->10 0x00007f19b40e5e00 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae5e00)
#<!-- -->11 0x00007f19b40e084d clang::Parser::ParseCompoundStatement(bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae084d)
#<!-- -->12 0x00007f19b4086c9d clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&amp;, bool, bool, clang::OpaquePtr&lt;clang::QualType&gt;&amp;, clang::SourceLocation&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa86c9d)
#<!-- -->13 0x00007f19b408b8f1 clang::Parser::ParseExprAfterUnaryExprOrTypeTrait(clang::Token const&amp;, bool&amp;, clang::OpaquePtr&lt;clang::QualType&gt;&amp;, clang::SourceRange&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa8b8f1)
#<!-- -->14 0x00007f19b4059901 clang::Parser::ParseTypeofSpecifier(clang::DeclSpec&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa59901)
#<!-- -->15 0x00007f19b4052321 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa52321)
#<!-- -->16 0x00007f19b40507b2 clang::Parser::ParseSpecifierQualifierList(clang::DeclSpec&amp;, clang::ImplicitTypenameContext, clang::AccessSpecifier, clang::Parser::DeclSpecContext) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa507b2)
#<!-- -->17 0x00007f19b408cc83 clang::Parser::ParseBlockId(clang::SourceLocation) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa8cc83)
#<!-- -->18 0x00007f19b408b1a3 clang::Parser::ParseBlockLiteralExpression() (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa8b1a3)
#<!-- -->19 0x00007f19b4084bf8 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&amp;, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa84bf8)
#<!-- -->20 0x00007f19b407f341 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa7f341)
#<!-- -->21 0x00007f19b407f219 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa7f219)
#<!-- -->22 0x00007f19b40dfaf5 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xadfaf5)
#<!-- -->23 0x00007f19b40ddff4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xaddff4)
#<!-- -->24 0x00007f19b40dd9a8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xadd9a8)
#<!-- -->25 0x00007f19b40e5e00 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae5e00)
#<!-- -->26 0x00007f19b40e6eaf clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xae6eaf)
#<!-- -->27 0x00007f19b4101503 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xb01503)
#<!-- -->28 0x00007f19b404e420 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa4e420)
#<!-- -->29 0x00007f19b41005a7 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec&amp;, clang::AccessSpecifier) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xb005a7)
#<!-- -->30 0x00007f19b40fffa1 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xafffa1)
#<!-- -->31 0x00007f19b40ff243 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xaff243)
#<!-- -->32 0x00007f19b40fd6e9 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xafd6e9)
#<!-- -->33 0x00007f19b40fd06f clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xafd06f)
#<!-- -->34 0x00007f19b4039606 clang::ParseAST(clang::Sema&amp;, bool, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa39606)
#<!-- -->35 0x00007f19b5d55ea5 clang::FrontendAction::Execute() (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x2755ea5)
#<!-- -->36 0x00007f19b5ccef94 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x26cef94)
#<!-- -->37 0x00007f19b5dd0074 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x27d0074)
#<!-- -->38 0x0000557d1805c918 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/usr/lib/llvm-17/bin/clang+0x12918)
#<!-- -->39 0x0000557d1805a415 (/usr/lib/llvm-17/bin/clang+0x10415)
#<!-- -->40 0x0000557d180595b6 clang_main(int, char**, llvm::ToolContext const&amp;) (/usr/lib/llvm-17/bin/clang+0xf5b6)
#<!-- -->41 0x0000557d18066912 main (/usr/lib/llvm-17/bin/clang+0x1c912)
#<!-- -->42 0x00007f19ab623a90 (/lib/x86_64-linux-gnu/libc.so.6+0x23a90)
#<!-- -->43 0x00007f19ab623b49 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23b49)
#<!-- -->44 0x0000557d18056de5 _start (/usr/lib/llvm-17/bin/clang+0xcde5)
clang-17: error: unable to execute command: Segmentation fault (core dumped)
clang-17: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 17.0.6 (++20231208085911+6009708b4367-1~exp1~20231208090013.78)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-17: note: diagnostic msg:
********************

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

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

</details>

@shafik
Copy link
Collaborator

shafik commented Jan 11, 2024

Confirmed: https://godbolt.org/z/nWaM7hb7s

Assertion:

clang++: /root/llvm-project/clang/include/clang/AST/Type.h:753:
const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const:
Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.

CC @rjmccall @Bigcheese

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" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

4 participants