Skip to content

Clang: __funcref induced ICE. #118233

@moonheart08

Description

@moonheart08
int hsGetFuncRefForGlobal( __funcref function );

This is sufficient to cause the Clang frontend to crash for WebAssembly. Godbolt demonstration: https://godbolt.org/z/T1TWd3qon

Backtrace:

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: /opt/compiler-explorer/clang-trunk/bin/clang -g -o /app/output.s -fno-verbose-asm -S -target wasm32 -fcolor-diagnostics -fno-crash-diagnostics -std=c23 <source>
1.	<source>:1:47: current parser token ')'
 #0 0x00000000039af2d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39af2d8)
 #1 0x00000000039ad424 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39ad424)
 #2 0x00000000038fdd58 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007e7769442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000000006fdf3a3 clang::ASTContext::removeAddrSpaceQualType(clang::QualType) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x6fdf3a3)
 #5 0x0000000006d9011d processTypeAttrs((anonymous namespace)::TypeProcessingState&, clang::QualType&, TypeAttrLocation, clang::ParsedAttributesView const&, clang::CUDAFunctionTarget) SemaType.cpp:0:0
 #6 0x0000000006d9369c GetDeclSpecTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::TypeSourceInfo*&) (.constprop.0) SemaType.cpp:0:0
 #7 0x0000000006da2c4c clang::Sema::GetTypeForDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x6da2c4c)
 #8 0x0000000006529c39 clang::Sema::ActOnParamDeclarator(clang::Scope*, clang::Declarator&, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+0x6529c39)
 #9 0x00000000061fb8c0 clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext, clang::ParsedAttributes&, llvm::SmallVectorImpl<clang::DeclaratorChunk::ParamInfo>&, clang::SourceLocation&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61fb8c0)
#10 0x00000000061fd79b clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61fd79b)
#11 0x00000000061ff352 clang::Parser::ParseDirectDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61ff352)
#12 0x00000000061f7adc clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61f7adc)
#13 0x0000000007838951 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x7838951)
#14 0x00000000061f3e24 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61f3e24)
#15 0x00000000061a2c87 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61a2c87)
#16 0x00000000061a3aa3 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61a3aa3)
#17 0x00000000061ad392 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61ad392)
#18 0x00000000061aec28 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61aec28)
#19 0x00000000061af170 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61af170)
#20 0x000000000619d2c2 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x619d2c2)
#21 0x00000000042fe835 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x42fe835)
#22 0x00000000045c8761 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x45c8761)
#23 0x000000000454832b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x454832b)
#24 0x00000000046b10c3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x46b10c3)
#25 0x0000000000ccb66c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xccb66c)
#26 0x0000000000cc3fad ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x00000000043467c9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x00000000038fe183 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38fe183)
#29 0x00000000043469e9 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#30 0x000000000430e21d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x430e21d)
#31 0x000000000430f21d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x430f21d)
#32 0x00000000043187cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x43187cc)
#33 0x0000000000cc8301 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xcc8301)
#34 0x0000000000b96244 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xb96244)
#35 0x00007e7769429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007e7769429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000cc3a4e _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xcc3a4e)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139```

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions