-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[Flang][OpenMP] Execution error of a WRITE statement with an unopened unit in a parallel region #68856
Comments
@llvm/issue-subscribers-openmp Author: Yusuke MINATO (yus3710-fj)
This is an issue from Fujitsu testsuite.
The execution of a program compiled by flang-new terminates with a fatal error. The following are the test program, Flang-new and gfortran execution result. ! test.f90
!$omp parallel
write(1,*) 'OK'
!$omp end parallel
end $ flang-new -v test.f90 -fopenmp
flang-new version 18.0.0 (https://github.com/llvm/llvm-project.git dae91f5dbc5bee579eac7f4cbb71e86f2934817f)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0
Selected GCC installation: /path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0
Candidate multilib: .;@<!-- -->m64
Selected multilib: .;@<!-- -->m64
"/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +neon -target-feature +v8a -o /tmp/test-f33630.o -x f95-cpp-input test.f90
"/usr/bin/ld" -pie -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -dynamic-linker /lib/ld-linux-aarch64.so.1 -o a.out /lib/../lib64/Scrt1.o /lib/../lib64/crti.o /path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0/crtbeginS.o -L/path/to/install/lib/clang/18/lib/aarch64-unknown-linux-gnu -L/path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0 -L/path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/test-f33630.o -L/path/to/install/lib -lFortran_main -lFortranRuntime -lFortranDecimal -lm -lomp -L/path/to/install/lib -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0/crtendS.o /lib/../lib64/crtn.o
$ ./a.out
$ OMP_NUM_THREADS=4 ./a.out
fatal Fortran runtime error(/path/to/test.f90:2): Attempted output to read-only file
Aborted (core dumped)
$ flang-new test.f90
$ ./a.out
$ cat fort.1
OK $ gfortran -v test.f90 -fopenmp
Driving: gfortran -v test.f90 -fopenmp -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)
:
$ OMP_NUM_THREADS=4 ./a.out
$ cat fort.1
OK
OK
OK
OK |
@llvm/issue-subscribers-flang-runtime Author: Yusuke MINATO (yus3710-fj)
This is an issue from Fujitsu testsuite.
The execution of a program compiled by flang-new terminates with a fatal error. The following are the test program, Flang-new and gfortran execution result. ! test.f90
!$omp parallel
write(1,*) 'OK'
!$omp end parallel
end $ flang-new -v test.f90 -fopenmp
flang-new version 18.0.0 (https://github.com/llvm/llvm-project.git dae91f5dbc5bee579eac7f4cbb71e86f2934817f)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0
Selected GCC installation: /path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0
Candidate multilib: .;@<!-- -->m64
Selected multilib: .;@<!-- -->m64
"/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +neon -target-feature +v8a -o /tmp/test-f33630.o -x f95-cpp-input test.f90
"/usr/bin/ld" -pie -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -dynamic-linker /lib/ld-linux-aarch64.so.1 -o a.out /lib/../lib64/Scrt1.o /lib/../lib64/crti.o /path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0/crtbeginS.o -L/path/to/install/lib/clang/18/lib/aarch64-unknown-linux-gnu -L/path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0 -L/path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/test-f33630.o -L/path/to/install/lib -lFortran_main -lFortranRuntime -lFortranDecimal -lm -lomp -L/path/to/install/lib -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /path/to/gcc/11.2.0/lib/gcc/aarch64-unknown-linux-gnu/11.2.0/crtendS.o /lib/../lib64/crtn.o
$ ./a.out
$ OMP_NUM_THREADS=4 ./a.out
fatal Fortran runtime error(/path/to/test.f90:2): Attempted output to read-only file
Aborted (core dumped)
$ flang-new test.f90
$ ./a.out
$ cat fort.1
OK $ gfortran -v test.f90 -fopenmp
Driving: gfortran -v test.f90 -fopenmp -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)
:
$ OMP_NUM_THREADS=4 ./a.out
$ cat fort.1
OK
OK
OK
OK |
It looks like the problem is here. llvm-project/flang/runtime/unit.cpp Lines 52 to 66 in 760658c
The first thread adds Unit 1 to UnitMap, and then opens/initializes the unit via OpenAnonymousUnit . And the other threads can find Unit 1 in UnitMap, but Unit 1 may not have been initialized, I mean mayWrite_ has not been set.llvm-project/flang/runtime/file.cpp Line 139 in b120fe8
Then got the IostatWriteToReadOnly error.llvm-project/flang/runtime/unit.cpp Lines 204 to 209 in b120fe8
|
…74468) In parallel regions `LookUpOrCreateAnonymous` may return an anonymous unit that has not yet been opened, which may cause a runtime error. This commit ensures that the returned anonymous unit has been opened. For details see: #68856 (comment) Fixes #68856
This is an issue from Fujitsu testsuite.
The execution of a program compiled by flang-new terminates with a fatal error.
In the program, there is a
WRITE
statement in a parallel region and the unit specified in that is not opened explicitly.The execution terminates normally when OpenMP is disabled.
The following are the test program, Flang-new and gfortran execution result.
The text was updated successfully, but these errors were encountered: