Closed
Description
Minimal reproducer:
INTEGER :: i
j=2
!$OMP PARALLEL default(private)
!$OMP critical(k2)
j=200
!$OMP END critical(k2)
!$OMP END PARALLEL
END
flang -fopenmp file.f90
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
flang: llvm-project/flang/lib/Semantics/resolve-directives.cpp:783: Symbol *Fortran::semantics::DirectiveAttributeVisitor<llvm::omp::Directive>::DeclareNewPrivateAccessEntity(const Symbol &, Symbol::Flag, Scope &) [T = llvm::omp::Directive]: Assertion `object.owner() != currScope()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: path/bin/flang -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -fopenmp -resource-dir path/lib/clang/20 -mframe-pointer=non-leaf -o /tmp/repo-017b14.o -x f95-cpp-input /tmp/repo.f90
#0 0x0000be97fd554c40 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (path/bin/flang+0x2f54c40)
#1 0x0000be97fd552abc llvm::sys::RunSignalHandlers() (path/bin/flang+0x2f52abc)
#2 0x0000be97fd5554ac SignalHandler(int) Signals.cpp:0:0
#3 0x0000ec1e70f3a8f8 (linux-vdso.so.1+0x8f8)
#4 0x0000ec1e708c7628 (/lib/aarch64-linux-gnu/libc.so.6+0x87628)
#5 0x0000ec1e7087cb3c raise (/lib/aarch64-linux-gnu/libc.so.6+0x3cb3c)
#6 0x0000ec1e70867e00 abort (/lib/aarch64-linux-gnu/libc.so.6+0x27e00)
#7 0x0000ec1e70875cbc (/lib/aarch64-linux-gnu/libc.so.6+0x35cbc)
#8 0x0000ec1e70875d2c (/lib/aarch64-linux-gnu/libc.so.6+0x35d2c)
#9 0x0000be97fe268bac Fortran::semantics::DirectiveAttributeVisitor<llvm::omp::Directive>::DeclareNewPrivateAccessEntity(Fortran::semantics::Symbol const&, Fortran::semantics::Symbol::Flag, Fortran::semantics::Scope&) (path/bin/flang+0x3c68bac)
#10 0x0000be97fe261448 Fortran::semantics::OmpAttributeVisitor::CreateImplicitSymbols(Fortran::semantics::Symbol const*, std::optional<Fortran::semantics::Symbol::Flag>) (path/bin/flang+0x3c61448)
#11 0x0000be97fe261954 Fortran::semantics::OmpAttributeVisitor::Post(Fortran::parser::Name const&) (path/flang+0x3c61954)
#12 0x0000be97fe2a0a78 void Fortran::parser::ForEachInTuple<0ul, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OmpCriticalDirective, std::__cxx11::list<Fortran::parser::ExecutionPartConstruct, std::allocator<Fortran::parser::ExecutionPartConstruct>>, Fortran::parser::OmpEndCriticalDirective>(std::tuple<Fortran::parser::OmpCriticalDirective, std::__cxx11::list<Fortran::parser::ExecutionPartConstruct, std::allocator<Fortran::parser::ExecutionPartConstruct>>, Fortran::parser::OmpEndCriticalDirective> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&), std::tuple<Fortran::parser::OmpCriticalDirective, std::__cxx11::list<Fortran::parser::ExecutionPartConstruct, std::allocator<Fortran::parser::ExecutionPartConstruct>>, Fortran::parser::OmpEndCriticalDirective>>(std::tuple<Fortran::parser::OmpCriticalDirective, std::__cxx11::list<Fortran::parser::ExecutionPartConstruct, std::allocator<Fortran::parser::ExecutionPartConstruct>>, Fortran::parser::OmpEndCriticalDirective> const&, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OmpCriticalDirective, std::__cxx11::list<Fortran::parser::ExecutionPartConstruct, std::allocator<Fortran::parser::ExecutionPartConstruct>>, Fortran::parser::OmpEndCriticalDirective>(std::tuple<Fortran::parser::OmpCriticalDirective, std::__cxx11::list<Fortran::parser::ExecutionPartConstruct, std::allocator<Fortran::parser::ExecutionPartConstruct>>, Fortran::parser::OmpEndCriticalDirective> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)) (/home/tomecl01/build/release-assertions/bin/flang+0x3ca0a78)
#13 0x0000be97fe29fb44 void Fortran::common::log2visit::Log2VisitHelper<5ul, 9ul, void, void
[...]
flang-20: error: unable to execute command: Aborted (core dumped)
flang-20: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 20.0.0git ([email protected]:llvm/llvm-project.git 7ec32094933bbf0201ea0670209c090a00bf8d83)
Target: aarch64-unknown-linux-gnu
The reproducer is simplified from these test cases: