[Bug libfortran/61187] New: valgrind errors if stdin is closed

jb at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 14 12:47:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61187

            Bug ID: 61187
           Summary: valgrind errors if stdin is closed
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jb at gcc dot gnu.org

In some cases STDIN_FILENO (0 in POSIX) can be closed. This happens e.g. for
rank != 0 MPI processes with MPICH2. This results in valgrind complaining about
uninitialized variables. 

Test program:

! Compile and run with
! gfortran -g otest.f90
! mpirun -np 2 valgrind --track-origins=yes a.out
program otest
  implicit none
  print *, "hello"
end program


Running via mpirun from mvapich2 1.8 and gcc 4.9.0 and strace shows:

fstat(0, fstat(0, 0x7ffff4ee09d0)                = -1 EBADF (Bad file
descriptor)

In unix.c(fd_to_stream) we don't check the return value of fstat before
accessing statbuf.

See https://gcc.gnu.org/ml/fortran/2014-04/msg00081.html for original bug
report.



More information about the Gcc-bugs mailing list