Re: [PATCH] Fix PR119136 Printing result of function that prints itself hangs

Jerry D <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
On 1/2/26 4:59 PM, Jakub Jelinek wrote:
> On Thu, Jan 01, 2026 at 01:43:50PM -0800, Jerry D wrote:
>> On 1/1/26 1:33 PM, Thomas Koenig wrote:
>>>> This will avoid potential undefined behavior on various systems. I
>>>> will make this change and test. If passes, OK for mainline?
>>>
>>> Good thinking.
>>>
>>> Your revised version is OK if it passes.
>>>
>>> Thanks a lot for the patch!
>>>
>>> Best regards
>>>
>>>       Thomas
>>>
>>
>> Pushed:
>>
>> commit 489423763d3c8b84d3409f4b200fb6b19ad96db3 (HEAD -> master,
>> origin/master, origin/HEAD)
>> Author: Jerry DeLisle <[email protected]>
>> Date:   Tue Dec 30 14:46:35 2025 -0800
>>
>>      Fortran: Generate a runtime error on recursive I/O
>>
>>              PR libfortran/119136
> 
> This broke a lot of libgomp tests on all major targets.
> Compare e.g.
> https://gcc.gnu.org/pipermail/gcc-testresults/2026-January/866363.html
> and
> https://gcc.gnu.org/pipermail/gcc-testresults/2026-January/866375.html
> FAIL: libgomp.fortran/appendix-a/a.2.1.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: libgomp.fortran/appendix-a/a.22.8.f90   -O0  execution test
> FAIL: libgomp.fortran/appendix-a/a.22.8.f90   -O1  execution test
> FAIL: libgomp.fortran/appendix-a/a.22.8.f90   -O2  execution test
> FAIL: libgomp.fortran/appendix-a/a.22.8.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.1.f90   -O0  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.1.f90   -O2  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.1.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.1.f90   -O3 -g  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.1.f90   -Os  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.2.f90   -O0  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.2.f90   -O1  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.2.f90   -O2  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.2.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.2.f90   -Os  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.3.f90   -O0  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.3.f90   -O1  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.3.f90   -O2  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.3.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.3.f90   -O3 -g  execution test
> FAIL: libgomp.fortran/appendix-a/a.28.3.f90   -Os  execution test
> FAIL: libgomp.fortran/depend-4.f90   -O  execution test
> FAIL: libgomp.fortran/omp_hello.f   -O  execution test
> FAIL: libgomp.fortran/omp_orphan.f   -O  execution test
> FAIL: libgomp.fortran/omp_workshare1.f   -O  execution test
> FAIL: libgomp.fortran/omp_workshare2.f   -O  execution test
> FAIL: libgomp.fortran/recursion1.f90   -O0  execution test
> FAIL: libgomp.fortran/recursion1.f90   -O1  execution test
> FAIL: libgomp.fortran/recursion1.f90   -O2  execution test
> FAIL: libgomp.fortran/recursion1.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: libgomp.fortran/recursion1.f90   -O3 -g  execution test
> FAIL: libgomp.fortran/recursion1.f90   -Os  execution test
> FAIL: libgomp.fortran/rwlock_2.f90   -O0  execution test
> FAIL: libgomp.fortran/rwlock_2.f90   -O1  execution test
> FAIL: libgomp.fortran/rwlock_2.f90   -O2  execution test
> FAIL: libgomp.fortran/rwlock_2.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> FAIL: libgomp.fortran/rwlock_2.f90   -O3 -g  execution test
> FAIL: libgomp.fortran/rwlock_2.f90   -Os  execution test
> all the errors in the logs look like
>   1: THREAD#            1 X =            5
>   2: THREAD#            0 X =            5
> At line 19 of file /home/jakub/src/gcc/libgomp/testsuite/libgomp.fortran/appendix-a/a.2.1.f90 (unit = 6, file = 'stdout')
> Fortran runtime error: Recursive I/O not allowed
> 
> Error termination. Backtrace:
> #0  0xf7e464b0 in data_transfer_init
>          at ../../../libgfortran/io/transfer.c:3132
> #1  0x8048457 in ???
> #2  0xf7a7da32 in gomp_thread_start
>          at ../../../libgomp/team.c:129
> #3  0xf78a51df in ???
> #4  0xf792b2d7 in ???
> #5  0xffffffff in ???
> 
> Recursive I/O shouldn't indeed be allowed, but multiple threads
> trying to transfer concurrently should be fine (of course, locking
> should be used for that).
> 
> 	Jakub
> 

I am looking for a way to check if libgomp is active and if so skip the check. 
If there is no such mechanism than I will revert the patch and we will need to 
find some other way to detect the recursive I/O.

Jerry
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.