llvm / llvm/llvm-project

[clang][OpenMP] Assertion `!R.isInvalid() && "operation was asserted to never fail!"' failed.

Open
#202,562 2 comments 0 reactions 0 assignees View on GitHub
clang:frontend clang:openmp crash generated by fuzzer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer:
https://godbolt.org/z/W18aGsxMW
```cpp
void foo() {
#pragma omp unroll partial
for (int i = {0}; i < 2; i++)
;
}
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/include/clang/Sema/Ownership.h:276: clang::Expr* clang::AssertSuccess(clang::ExprResult): Assertion `!R.isInvalid() && "operation was asserted to never fail!"' 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. :5:1: current parser token '}'
2. :1:12: parsing function body 'foo'
3. :1:12: in compound statement ('{}')
#0 0x000000000437c168 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x437c168)
#1 0x0000000004378fa4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4378fa4)
#2 0x00000000043795c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43795c4)
#3 0x00000000042b4af8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x000077d899845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x000077d89989eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#6 0x000077d89984527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x000077d8998288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x000077d89982881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x000077d89983b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000007406e13 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7406e13)
#11 0x00000000075205c0 clang::SemaOpenMP::ActOnOpenMPUnrollDirective(llvm::ArrayRef, clang::Stmt*, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x75205c0)
#12 0x00000000074a4b90 clang::SemaOpenMP::ActOnOpenMPExecutableDirective(llvm::omp::Directive, clang::DeclarationNameInfo const&, llvm::omp::Directive, llvm::ArrayRef, clang::Stmt*, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74a4b90)
#13 0x0000000006d0f5ce clang::Parser::ParseOpenMPExecutableDirective(clang::Parser::ParsedStmtContext, llvm::omp::Directive, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d0f5ce)
#14 0x0000000006d1c1b7 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d1c1b7)
#15 0x0000000006d3bee4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d3bee4)
#16 0x0000000006d3d749 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d3d749)
#17 0x0000000006d45f6e clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d45f6e)
#18 0x0000000006d4678a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4678a)
#19 0x0000000006c4a603 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4a603)
#20 0x0000000006c81913 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+++0x6c81913)
#21 0x0000000006c3db4b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c3db4b)
#22 0x0000000006c3e34f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c3e34f)
#23 0x0000000006c45e11 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c45e11)
#24 0x0000000006c46d45 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c46d45)
#25 0x0000000006c47130 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c47130)
#26 0x0000000006c27bc3 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c27bc3)
#27 0x0000000004e6ab58 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e6ab58)
#28 0x00000000051a1688 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51a1688)
#29 0x000000000511e8cd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x511e8cd)
#30 0x00000000052a179d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52a179d)
#31 0x0000000000e214ff cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe214ff)
#32 0x0000000000e17eba ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#33 0x0000000000e1803d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#34 0x0000000004edd539 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#35 0x00000000042b4f34 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42b4f34)
#36 0x0000000004eddb86 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#37 0x0000000004e9a062 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e9a062)
#38 0x0000000004e9b00e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e9b00e)
#39 0x0000000004ea3215 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ea3215)
#40 0x0000000000e1d8ec clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe1d8ec)
#41 0x0000000000cc173a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc173a)
#42 0x000077d89982a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#43 0x000077d89982a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#44 0x0000000000e17955 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe17955)
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

Run the supplied C++ reproducer with -fopenmp using an assertions-enabled clang, then inspect clang::SemaOpenMP::ActOnOpenMPUnrollDirective and the AssertSuccess call in tools/clang/include/clang/Sema/Ownership.h. Trace why this OpenMP unroll form produces an invalid expression; done means the reproducer no longer asserts and has regression coverage for the diagnostic or successful compilation behavior.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.