public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/61187] New: valgrind errors if stdin is closed
@ 2014-05-14 12:47 jb at gcc dot gnu.org
  2014-05-16 20:37 ` [Bug libfortran/61187] " jb at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jb at gcc dot gnu.org @ 2014-05-14 12:47 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/61187] valgrind errors if stdin is closed
  2014-05-14 12:47 [Bug libfortran/61187] New: valgrind errors if stdin is closed jb at gcc dot gnu.org
@ 2014-05-16 20:37 ` jb at gcc dot gnu.org
  2014-05-16 20:43 ` jb at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jb at gcc dot gnu.org @ 2014-05-16 20:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Fri May 16 20:37:13 2014
New Revision: 210527

URL: http://gcc.gnu.org/viewcvs?rev=210527&root=gcc&view=rev
Log:
PR 61187 Fix use of uninitialized memory.

2014-05-16  Janne Blomqvist  <jb@gcc.gnu.org>

    PR libfortran/61187
    * io/unix.c (raw_close): Check if s->fd is -1.
    (fd_to_stream): Check return value of fstat(), handle error.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/unix.c


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/61187] valgrind errors if stdin is closed
  2014-05-14 12:47 [Bug libfortran/61187] New: valgrind errors if stdin is closed jb at gcc dot gnu.org
  2014-05-16 20:37 ` [Bug libfortran/61187] " jb at gcc dot gnu.org
@ 2014-05-16 20:43 ` jb at gcc dot gnu.org
  2014-05-16 20:48 ` jb at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jb at gcc dot gnu.org @ 2014-05-16 20:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Fri May 16 20:42:56 2014
New Revision: 210529

URL: http://gcc.gnu.org/viewcvs?rev=210529&root=gcc&view=rev
Log:
PR 61187 Fix use of uninitialized data.

2014-05-16  Janne Blomqvist  <jb@gcc.gnu.org>

    Backport from trunk:
    PR libfortran/61187
    * io/unix.c (raw_close): Check if s->fd is -1.
    (fd_to_stream): Check return value of fstat(), handle error.

Modified:
    branches/gcc-4_7-branch/libgfortran/ChangeLog
    branches/gcc-4_7-branch/libgfortran/io/unix.c


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/61187] valgrind errors if stdin is closed
  2014-05-14 12:47 [Bug libfortran/61187] New: valgrind errors if stdin is closed jb at gcc dot gnu.org
  2014-05-16 20:37 ` [Bug libfortran/61187] " jb at gcc dot gnu.org
  2014-05-16 20:43 ` jb at gcc dot gnu.org
@ 2014-05-16 20:48 ` jb at gcc dot gnu.org
  2014-05-20 18:16 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jb at gcc dot gnu.org @ 2014-05-16 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Fri May 16 20:48:17 2014
New Revision: 210530

URL: http://gcc.gnu.org/viewcvs?rev=210530&root=gcc&view=rev
Log:
PR 61187 Fix use of uninitialized data.

2014-05-16  Janne Blomqvist  <jb@gcc.gnu.org>

    Backport from trunk:
    PR libfortran/61187
    * io/unix.c (raw_close): Check if s->fd is -1.
    (fd_to_stream): Check return value of fstat(), handle error.

Modified:
    branches/gcc-4_9-branch/libgfortran/ChangeLog
    branches/gcc-4_9-branch/libgfortran/io/unix.c


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/61187] valgrind errors if stdin is closed
  2014-05-14 12:47 [Bug libfortran/61187] New: valgrind errors if stdin is closed jb at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-05-16 20:48 ` jb at gcc dot gnu.org
@ 2014-05-20 18:16 ` dominiq at lps dot ens.fr
  2014-05-25 19:29 ` jb at gcc dot gnu.org
  2014-05-25 19:30 ` jb at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-05-20 18:16 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-05-20
     Ever confirmed|0                           |1

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
This pr is fixed on all open branches, but 4.8. So NEW seems the right status.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/61187] valgrind errors if stdin is closed
  2014-05-14 12:47 [Bug libfortran/61187] New: valgrind errors if stdin is closed jb at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2014-05-20 18:16 ` dominiq at lps dot ens.fr
@ 2014-05-25 19:29 ` jb at gcc dot gnu.org
  2014-05-25 19:30 ` jb at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jb at gcc dot gnu.org @ 2014-05-25 19:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Sun May 25 19:29:00 2014
New Revision: 210914

URL: http://gcc.gnu.org/viewcvs?rev=210914&root=gcc&view=rev
Log:
PR 61187 Avoid reading uninitialized memory.

2014-05-25  Janne Blomqvist  <jb@gcc.gnu.org>

    Backport from trunk.
    PR libfortran/61187
    * io/unix.c (raw_close): Check if s->fd is -1.
    (fd_to_stream): Check return value of fstat(), handle error.

Modified:
    branches/gcc-4_8-branch/libgfortran/ChangeLog
    branches/gcc-4_8-branch/libgfortran/io/unix.c


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/61187] valgrind errors if stdin is closed
  2014-05-14 12:47 [Bug libfortran/61187] New: valgrind errors if stdin is closed jb at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2014-05-25 19:29 ` jb at gcc dot gnu.org
@ 2014-05-25 19:30 ` jb at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jb at gcc dot gnu.org @ 2014-05-25 19:30 UTC (permalink / raw)
  To: gcc-bugs

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

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Fixed on 4.7/4.8/4.9/trunk, closing.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-25 19:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-14 12:47 [Bug libfortran/61187] New: valgrind errors if stdin is closed jb at gcc dot gnu.org
2014-05-16 20:37 ` [Bug libfortran/61187] " jb at gcc dot gnu.org
2014-05-16 20:43 ` jb at gcc dot gnu.org
2014-05-16 20:48 ` jb at gcc dot gnu.org
2014-05-20 18:16 ` dominiq at lps dot ens.fr
2014-05-25 19:29 ` jb at gcc dot gnu.org
2014-05-25 19:30 ` jb at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).