llvm / llvm/llvm-project

[clang][OpenMP] Assertion `D.DeclIdent && "Identifier expected."' failed.

Open
#217,882 4 comments 0 reactions 0 assignees View on GitHub
clang:frontend clang:openmp crash-on-invalid generated by fuzzer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer:
https://godbolt.org/z/q3cGrqeWY
```cpp
void foo() {
#pragma omp depobj depend(iterator(int))
}
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaOpenMP.cpp:26717: clang::ExprResult clang::SemaOpenMP::ActOnOMPIteratorExpr(clang::Scope*, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef): Assertion `D.DeclIdent && "Identifier expected."' 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 -fopenmp
1. :2:40: current parser token ')'
2. :1:12: parsing function body 'foo'
3. :1:12: in compound statement ('{}')
#0 0x000000000440f3f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x440f3f8)
#1 0x000000000440c2a4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x440c2a4)
#2 0x000000000440c8dc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x440c8dc)
#3 0x000000000434af68 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x000072abe0245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x000072abe029ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
#6 0x000072abe024527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x000072abe02288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x000072abe022881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x000072abe023b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x00000000075bcc2c clang::SemaOpenMP::ActOnOMPIteratorExpr(clang::Scope*, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x75bcc2c)
#11 0x0000000006e33e34 clang::Parser::ParseOpenMPIteratorsExpr() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e33e34)
#12 0x0000000006e357ab clang::Parser::ParseOpenMPVarList(llvm::omp::Directive, llvm::omp::Clause, llvm::SmallVectorImpl&, clang::SemaOpenMP::OpenMPVarListDataTy&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e357ab)
#13 0x0000000006e37c72 clang::Parser::ParseOpenMPVarListClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e37c72)
#14 0x0000000006e37ff1 clang::Parser::ParseOpenMPClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e37ff1)
#15 0x0000000006e39f49 clang::Parser::ParseOpenMPExecutableDirective(clang::Parser::ParsedStmtContext, llvm::omp::Directive, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e39f49)
#16 0x0000000006e45b45 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e45b45)
#17 0x0000000006e66c1c clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e66c1c)
#18 0x0000000006e68109 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e68109)
#19 0x0000000006e70625 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e70625)
#20 0x0000000006e70e6a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e70e6a)
#21 0x0000000006d6df5d clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d6df5d)
#22 0x0000000006db79c6 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+++0x6db79c6)
#23 0x0000000006d6238b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d6238b)
#24 0x0000000006d62b7f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d62b7f)
#25 0x0000000006d6f338 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d6f338)
#26 0x0000000006d70295 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d70295)
#27 0x0000000006d70680 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d70680)
#28 0x0000000006d4d1bc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4d1bc)
#29 0x0000000004f19c18 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f19c18)
#30 0x0000000005246988 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5246988)
#31 0x00000000051d46dd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51d46dd)
#32 0x000000000531c3dd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x531c3dd)
#33 0x0000000000db239c cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb239c)
#34 0x0000000000da8faa ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#35 0x0000000000da912d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#36 0x0000000004f92719 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#37 0x000000000434b3a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x434b3a4)
#38 0x0000000004f93285 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#39 0x0000000004f4b102 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f4b102)
#40 0x0000000004f4fa67 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f4fa67)
#41 0x0000000004f5a055 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f5a055)
#42 0x0000000000dae88a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdae88a)
#43 0x0000000000cca41a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcca41a)
#44 0x000072abe022a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#45 0x000072abe022a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#46 0x0000000000da8955 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda8955)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```

Contributor guide

Open the contributing guide

Research direction

Start with clang::Parser::ParseOpenMPIteratorsExpr and clang::SemaOpenMP::ActOnOMPIteratorExpr in clang/lib/Sema/SemaOpenMP.cpp, using the supplied OpenMP depobj reproducer and backtrace. Run clang++ with -fopenmp on the example, then trace how the missing iterator identifier is handled. Done means the input no longer triggers the assertion and is handled as a compiler diagnostic or other established error path.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.