-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Comments
@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> PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: cc -v test.c PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: </details> <details>
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: <details> <summary>Clang 17 dump from Linux </summary>
</details> |
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. |
The following code do cause a segfault on clang.
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
The text was updated successfully, but these errors were encountered: