Skip to content

[Flang][OpenMP] crashes on invalid goto inside OpenMP parallel/master block #143229

Open
@k-arrows

Description

@k-arrows

Reproducer:
https://godbolt.org/z/fvvGoP896

!$omp parallel
do i = 1, 2
  goto 10
end do
!$omp master
10 print *, i
!$omp end master
!$omp end parallel
end

Backtrace:

flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
/app/example.f90:5:7: warning: OpenMP directive MASTER has been deprecated, please use MASKED instead.
  !$omp master
        ^^^^^^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang -fc1 -triple x86_64-unknown-linux-gnu -S -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -fopenmp -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20250606/lib/clang/21 -mframe-pointer=all -o /app/output.s -x f95 /app/example.f90
 #0 0x0000000003eadc28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x3eadc28)
 #1 0x0000000003eab7e4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x000078f2e8e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000000000939f0c7 mlir::SuccessorRange::SuccessorRange(mlir::Block*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x939f0c7)
 #4 0x0000000007c7ecde mlir::eraseUnreachableBlocks(mlir::RewriterBase&, llvm::MutableArrayRef<mlir::Region>) (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x7c7ecde)
 #5 0x0000000004342421 (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
 #6 0x0000000004344174 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x4344174)
 #7 0x00000000041b8e86 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x41b8e86)
 #8 0x0000000003f050c5 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x3f050c5)
 #9 0x0000000003ef3c77 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x3ef3c77)
#10 0x0000000003f0ea33 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x3f0ea33)
#11 0x0000000002203cba fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x2203cba)
#12 0x00000000020b97e6 main (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x20b97e6)
#13 0x000078f2e8e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#14 0x000078f2e8e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#15 0x0000000002202685 _start (/opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin/flang+0x2202685)
flang-21: error: unable to execute command: Segmentation fault (core dumped)
flang-21: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 21.0.0git (https://github.com/llvm/llvm-project.git de3a9ea510fecd501b4dd57534cf300d1c9622c9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20250606/bin
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
flang-21: note: diagnostic msg: 

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions