Skip to content

clangtk crashes when processing a simple assignment loop wrapped by #pragma omp unroll #63570

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

Closed
wierton opened this issue Jun 28, 2023 · 2 comments · Fixed by #65862
Closed
Assignees
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] openmp

Comments

@wierton
Copy link
Member

wierton commented Jun 28, 2023

The testcase (compiled with clang -fopenmp-simd small.c):

void f(float *a, float *b) {
#pragma omp unroll
  for (int i = 0; i < 128; i++) {
    a[i] = b[i];
  }
}

Compiler Explorer: https://gcc.godbolt.org/z/Toh4vj1YP

Compiler version:

clang version 17.0.0 (https://github.com/llvm/llvm-project.git 12e9c7aaa66b7624b5d7666ce2794d912bf9e4b7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0

Crash recovery log:

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 -gdwarf-4 -g -o /app/output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -fopenmp-simd <source>
1.	<eof> parser at end of file
2.	<source>:1:6: LLVM IR generation of declaration 'f'
3.	<source>:1:6: Generating code for declaration 'f'
 #0 0x0000556a6b12089f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x362e89f)
 #1 0x0000556a6b11e8cc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x362c8cc)
 #2 0x0000556a6b06e588 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f61fd6dc420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x0000556a6e919644 clang::CapturedStmt::Capture::getCaptureKind() const (/opt/compiler-explorer/clang-trunk/bin/clang+0x6e27644)
 #5 0x0000556a6b457734 clang::CodeGen::CodeGenFunction::EmitSimpleOMPExecutableDirective(clang::OMPExecutableDirective const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3965734)
 #6 0x0000556a6b42253d clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x393053d)
 #7 0x0000556a6b4284b9 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39364b9)
 #8 0x0000556a6b489037 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3997037)
 #9 0x0000556a6b494156 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39a2156)
#10 0x0000556a6b4ed36a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39fb36a)
#11 0x0000556a6b4e9675 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39f7675)
#12 0x0000556a6b4e9fe0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39f7fe0)
#13 0x0000556a6b4f19a7 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#14 0x0000556a6c2bf09e (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#15 0x0000556a6c2b145d clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk/bin/clang+0x47bf45d)
#16 0x0000556a6d67a6d4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b886d4)
#17 0x0000556a6c2bc5ad clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x47ca5ad)
#18 0x0000556a6bb97f21 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x40a5f21)
#19 0x0000556a6bb1d353 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x402b353)
#20 0x0000556a6bc78ec3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4186ec3)
#21 0x0000556a6899491c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xea291c)
#22 0x0000556a6898ffdf ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x0000556a6b96ef5d 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
#24 0x0000556a6b06ea07 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x357ca07)
#25 0x0000556a6b96f3fc 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
#26 0x0000556a6b9362be clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e442be)
#27 0x0000556a6b936c8d 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+0x3e44c8d)
#28 0x0000556a6b94135c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e4f35c)
#29 0x0000556a689924df clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xea04df)
#30 0x0000556a6888e7c5 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd9c7c5)
#31 0x00007f61fd18a083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#32 0x0000556a6898c2be _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xe9a2be)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
@EugeneZelenko EugeneZelenko added clang:codegen IR generation bugs: mangling, exceptions, etc. crash Prefer [crash-on-valid] or [crash-on-invalid] openmp and removed new issue labels Jun 28, 2023
@llvmbot
Copy link
Member

llvmbot commented Jun 28, 2023

@llvm/issue-subscribers-clang-codegen

@llvmbot
Copy link
Member

llvmbot commented Jun 28, 2023

@llvm/issue-subscribers-openmp

@shiltian shiltian added the confirmed Verified by a second party label Sep 9, 2023
shiltian added a commit to shiltian/llvm-project that referenced this issue Sep 9, 2023
The front end doesn't create captured region for unroll directive. This leads to
a crash when `-fopenmp-simd` is used, as reported in llvm#63570.

Fix llvm#63570.
@shiltian shiltian self-assigned this Sep 9, 2023
shiltian added a commit that referenced this issue Sep 9, 2023
The front end doesn't create captured stmt for unroll directive. This
leads to
a crash when `-fopenmp-simd` is used, as reported in #63570.

Fix #63570.
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this issue Sep 19, 2023
The front end doesn't create captured stmt for unroll directive. This
leads to
a crash when `-fopenmp-simd` is used, as reported in llvm#63570.

Fix llvm#63570.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] openmp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants