Bug 95546 - Random Fortran test failures
Summary: Random Fortran test failures
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: testsuite-fail
Depends on:
Blocks:
 
Reported: 2020-06-04 22:41 UTC by H.J. Lu
Modified: 2021-12-15 20:17 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-06-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2020-06-04 22:41:01 UTC
I got random failures:

t line 12 of file /export/gnu/import/git/gcc-test-master-intel64/src-master/gcc/testsuite/gfortran.dg/eof_4.f90 (unit = 99)
Fortran runtime error: Cannot open file 'test.dat': File exists 

Error termination. Backtrace:
#0  0x7f6dc5baf37c in already_open
        at ../../../src-master/libgfortran/io/open.c:720
#1  0x4012bb in ??? 
#2  0x4034df in ??? 
#3  0x7f6dc55e2071 in ??? 
#4  0x40115d in ??? 
#5  0xffffffffffffffff in ??? 
FAIL: gfortran.dg/eof_4.f90   -O0  execution test

There are

gfortran.dg/direct_io_12.f90:open(99, file='test.dat', form='unformatted', access='direct', recl=size*8)
gfortran.dg/endfile.f90:      open(unit=10,file='test.dat',access='sequential',status='replace')
gfortran.dg/endfile.f90:      open(unit=10,file='test.dat',access='sequential',status='old')
gfortran.dg/eof_4.f90:open(99, file="test.dat", access="stream", form="unformatted", status="new")
gfortran.dg/eof_4.f90:open(99, file="test.dat")
gfortran.dg/eof_4.f90:open(99, file="test.dat", access="stream", form="unformatted", status="new")
gfortran.dg/eof_4.f90:open(99, file="test.dat")
gfortran.dg/eof_4.f90:open(99, file="test.dat", access="stream", form="unformatted", status="new")
gfortran.dg/eof_4.f90:open(99, file="test.dat")
gfortran.dg/eof_4.f90:open(99, file="test.dat", access="stream", form="unformatted", status="new")
gfortran.dg/eof_4.f90:open(99, file="test.dat")
gfortran.dg/eof_4.f90:open(99, file="test.dat", access="stream", form="unformatted", status="new")
gfortran.dg/eof_4.f90:open(99, file="test.dat")
gfortran.dg/eof_4.f90:open(99, file="test.dat", access="stream", form="unformatted", status="new")
gfortran.dg/eof_4.f90:open(99, file="test.dat")
gfortran.dg/eof_4.f90:open(99, file="test.dat", access="stream", form="unformatted", status="new")
gfortran.dg/eof_4.f90:open(99, file="test.dat")
gfortran.dg/implied_do_io_1.f90:  open(10,file="test.dat")
gfortran.dg/list_read_7.f90:open(unit=20, file='test.dat',form='FORMATTED', status="replace")
gfortran.dg/namelist_76.f90:  open(unit=10,form='formatted',status='replace',action='write',file='test.dat')
gfortran.dg/namelist_97.f90:  open  (unit=10, file='test.dat', form=my_form)
gfortran.dg/open_new_segv.f90:  ! Make sure pr64770test.dat exists
gfortran.dg/open_new_segv.f90:  open(99, file="pr64770test.dat", status="replace")
gfortran.dg/open_new_segv.f90:  open(99, file="pr64770test.dat", access="stream", form="unformatted", &
gfortran.dg/open_new_segv.f90:! { dg-output "Fortran runtime error: Cannot open file .pr64770test.dat.:" }
gfortran.dg/open_new_segv.f90:! { dg-final { remote_file build delete "pr64770test.dat" } }
gfortran.dg/read_eof_8.f90:  open(unit=25,file="test.dat",status="replace", &
Comment 1 H.J. Lu 2020-06-04 22:41:34 UTC
It happens with "make -jN check".
Comment 2 kargls 2020-06-04 22:49:18 UTC
(In reply to H.J. Lu from comment #1)
> It happens with "make -jN check".

The Fortran code is correct.

If 'make -jN check' is trying to build and execute multiple
versions of eof_4.f90 in parallel, then that won't work.  
Looks like you have a race condition with parallel make.
Comment 3 Dominique d'Humieres 2020-06-04 23:46:00 UTC
I have seen that too with -j8.

AFAICT the problem is that the test expects there is no file 'test.dat'.
Comment 4 Jerry DeLisle 2020-06-05 15:46:18 UTC
I am curious, did this just start happening or is it a long time issue just reported.  Locking mecahnisms were adjusted recently I believe.
Comment 5 Steve Kargl 2020-06-05 17:25:58 UTC
On Fri, Jun 05, 2020 at 03:46:18PM +0000, jvdelisle at charter dot net wrote:
> 
> I am curious, did this just start happening or is it a long time issue just
> reported.  Locking mecahnisms were adjusted recently I believe.
> 

What locking are you referring to?  If it some recent changes
to libgfortran's pthread locking, then I think that has nothing
to do with the problem reported here.

The code eof_4.f90 runs multiple tests.  The looks like

  open(unit=99, file='test.dat', status='new')
  !
  ! Test 1
  !
  close(99, status='delete')

  open(unit=99, file='test.dat', status='new')
  !
  ! Test 2
  !
  close(99, status='delete')

  open(unit=99, file='test.dat', status='new')
  !
  ! Test 3
  !
  close(99, status='delete')

The above is actually testing Fortran feature.

HJ Lu reported problems with 'make -jN', which suggests that
eof_4.f90 is being compiled and executed in parallel.  That
is subject to races.  Dejagnu needs to be told that eof_4.f90
cannot be run in parallel.  If it is not possible to defeat
dejagnu, then the test will need to changed to use a unique
file name

  character(len=20) name  
  write(name, '(A,I0,A)') 'tmp', getpid(), '.dat'
 
  open(unit=99, file=name, status='new')
  !
  ! Test 1
  !
  close(99, status='delete')

The test could also be adjusted to use inquire() and sleep()
(need to check syntax)

1 inquire(file='test.dat', exists=stat)
  if (stat == 1) then
     call sleep(2)
     goto 1
  end if
Comment 6 Dominique d'Humieres 2020-06-05 19:51:33 UTC
> I am curious, did this just start happening or is it a long time issue just reported.

The test is quite old: Feb 18  2018. I did not see any failure for it until now (one instance).