llvm / llvm/llvm-project

[clang] Assertion `makeInsertToken(ProfileID.computeHash()) == Token && "node profile must match the insert token"' failed with -fms-compatibility

Open
#223,150 3 comments 0 reactions 0 assignees View on GitHub
clang:frontend crash-on-invalid generated by fuzzer regression:24
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer:
https://godbolt.org/z/zbGGaoxfn
```cpp
void foo(int bar[__unaligned]) {}
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:533: void llvm::FoldingSetImpl::insert(T*, llvm::FoldingSetInsertToken) [with T = clang::IncompleteArrayType; Trait = llvm::FoldingSetTrait]: Assertion `makeInsertToken(ProfileID.computeHash()) == Token && "node profile must match the insert token"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fms-compatibility
1. :1:30: current parser token ')'
#0 0x00000000044b9718 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b9718)
#1 0x00000000044b6974 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b6974)
#2 0x00000000044b6fac llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b6fac)
#3 0x00000000043f35c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007501df445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007501df49ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
#6 0x00007501df44527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007501df4288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007501df42881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007501df43b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000007e51e3b clang::ASTContext::getIncompleteArrayType(clang::QualType, clang::ArraySizeModifier, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e51e3b)
#11 0x0000000007ae797f clang::Sema::BuildArrayType(clang::QualType, clang::ArraySizeModifier, clang::Expr*, unsigned int, clang::SourceRange, clang::DeclarationName) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ae797f)
#12 0x0000000007afd2ab GetFullTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*) SemaType.cpp:0:0
#13 0x0000000007b02645 clang::Sema::GetTypeForDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b02645)
#14 0x000000000721e41c clang::Sema::ActOnParamDeclarator(clang::Scope*, clang::Declarator&, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x721e41c)
#15 0x0000000006e7234b clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext, clang::ParsedAttributes&, llvm::SmallVectorImpl&, clang::SourceLocation&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e7234b)
#16 0x0000000006e7361a clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e7361a)
#17 0x0000000006e753e9 clang::Parser::ParseDirectDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e753e9)
#18 0x0000000006e5d49f clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e5d49f)
#19 0x0000000008954521 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8954521)
#20 0x0000000006e76977 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e76977)
#21 0x0000000006e2219b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e2219b)
#22 0x0000000006e2298f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e2298f)
#23 0x0000000006e2f3f8 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e2f3f8)
#24 0x0000000006e30335 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e30335)
#25 0x0000000006e30720 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e30720)
#26 0x0000000006e0c7fc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e0c7fc)
#27 0x0000000004fcee98 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fcee98)
#28 0x00000000052efb78 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52efb78)
#29 0x000000000527d78d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x527d78d)
#30 0x00000000053c439d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53c439d)
#31 0x0000000000d9173c cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9173c)
#32 0x0000000000d8845a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#33 0x0000000000d885dd int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#34 0x0000000005043169 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#35 0x00000000043f39c4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43f39c4)
#36 0x0000000005043cd5 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#37 0x0000000005002102 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5002102)
#38 0x0000000005006a67 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5006a67)
#39 0x0000000005010fc5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5010fc5)
#40 0x0000000000d8dc4a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd8dc4a)
#41 0x0000000000ccb5ea main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xccb5ea)
#42 0x00007501df42a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#43 0x00007501df42a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#44 0x0000000000d87e05 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd87e05)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGABRT (6)
Compiler returned: 134
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the assertion with the linked Compiler Explorer example and -fms-compatibility. Read clang::ASTContext::getIncompleteArrayType, clang::Sema::BuildArrayType, and the SemaType.cpp path shown in the backtrace. Done means the reproducer no longer aborts with the node-profile assertion and the behavior is covered by an appropriate Clang test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.