public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error
@ 2015-08-27  2:54 urbanjost at comcast dot net
  2015-08-27  4:18 ` [Bug fortran/67367] " jvdelisle at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: urbanjost at comcast dot net @ 2015-08-27  2:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67367
           Summary: Program crashes on READ(IOSTAT=IOS, ...) on directory
                    OPEN()ed without error
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: urbanjost at comcast dot net
  Target Milestone: ---

Created attachment 36257
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36257&action=edit
commands and their output show system type, compiler version, source code and
saved temp files

When I read a list of filenames from the command line the list can easily
contain non-standard-file names such as directories. If I OPEN() a name that is
a directory with default options I get an error on the OPEN() (IOSTAT=21) and
IOMSG reports "file is a directory". But I am opening the files as read-only
streams. With those options the OPEN() gives no errors. But the first READ() of
the files causes the program to halt abruptly with no messages. No core file is
produced; I/O on open files is not flushed or closed properly.

I would have expected the OPEN() to have failed with an error; or if it is
legal to open a directory as a stream (which would be useful but surprising) I
would expect the READ to have trapped the error as the READ() uses IOSTAT=.


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

* [Bug fortran/67367] Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error
  2015-08-27  2:54 [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error urbanjost at comcast dot net
@ 2015-08-27  4:18 ` jvdelisle at gcc dot gnu.org
  2015-08-28 18:58 ` jvdelisle at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-08-27  4:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-08-27
                 CC|                            |jvdelisle at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ba152e in buf_read (s=0x6063b0, buf=<optimized out>, 
    nbyte=<optimized out>) at ../../../trunk/libgfortran/io/unix.c:535
535               memcpy (p, s->buffer, did_read);


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

* [Bug fortran/67367] Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error
  2015-08-27  2:54 [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error urbanjost at comcast dot net
  2015-08-27  4:18 ` [Bug fortran/67367] " jvdelisle at gcc dot gnu.org
@ 2015-08-28 18:58 ` jvdelisle at gcc dot gnu.org
  2015-08-28 22:05 ` sgk at troutmask dot apl.washington.edu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-08-28 18:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jvdelisle at gcc dot gnu.org

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I wonder if these have been lurking since day 1.


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

* [Bug fortran/67367] Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error
  2015-08-27  2:54 [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error urbanjost at comcast dot net
  2015-08-27  4:18 ` [Bug fortran/67367] " jvdelisle at gcc dot gnu.org
  2015-08-28 18:58 ` jvdelisle at gcc dot gnu.org
@ 2015-08-28 22:05 ` sgk at troutmask dot apl.washington.edu
  2015-08-29  0:16 ` jvdelisle at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-08-28 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Fri, Aug 28, 2015 at 06:58:25PM +0000, jvdelisle at gcc dot gnu.org wrote:
> 
> --- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> I wonder if these have been lurking since day 1.
> 

I haven't gone looking for the origin, but from
my last excursion through io.c I think it was written
to accept what is standard conforming with very little
consideration from wrong code.


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

* [Bug fortran/67367] Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error
  2015-08-27  2:54 [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error urbanjost at comcast dot net
                   ` (2 preceding siblings ...)
  2015-08-28 22:05 ` sgk at troutmask dot apl.washington.edu
@ 2015-08-29  0:16 ` jvdelisle at gcc dot gnu.org
  2015-08-29 15:39 ` jvdelisle at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-08-29  0:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Created attachment 36265
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36265&action=edit
A preliminary patch - not final

This patch catches the segfault and we end up with an EOF error. It bothers me
that we get into this with both source and destination of the raw_read with bad
pointers, so I am going to explore further.

If one uses a regular open command, READ/WRITE is specified and one can not
write to a directory, so it throws the expected OS error. In the case of read
only, one cany open a directory, but it is only intended to be read with
readdir and not read (see man read and man readdir)

Stay tuned.


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

* [Bug fortran/67367] Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error
  2015-08-27  2:54 [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error urbanjost at comcast dot net
                   ` (3 preceding siblings ...)
  2015-08-29  0:16 ` jvdelisle at gcc dot gnu.org
@ 2015-08-29 15:39 ` jvdelisle at gcc dot gnu.org
  2015-08-29 15:53 ` jvdelisle at gcc dot gnu.org
  2015-08-31  0:14 ` jvdelisle at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-08-29 15:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Author: jvdelisle
Date: Sat Aug 29 15:38:39 2015
New Revision: 227320

URL: https://gcc.gnu.org/viewcvs?rev=227320&root=gcc&view=rev
Log:
2015-08-29 Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libgfortran/67367
        * io/unix.c (buf_read): Check for error condition and if found
        return the error code.

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


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

* [Bug fortran/67367] Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error
  2015-08-27  2:54 [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error urbanjost at comcast dot net
                   ` (4 preceding siblings ...)
  2015-08-29 15:39 ` jvdelisle at gcc dot gnu.org
@ 2015-08-29 15:53 ` jvdelisle at gcc dot gnu.org
  2015-08-31  0:14 ` jvdelisle at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-08-29 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Author: jvdelisle
Date: Sat Aug 29 15:52:43 2015
New Revision: 227321

URL: https://gcc.gnu.org/viewcvs?rev=227321&root=gcc&view=rev
Log:
2015-08-29 Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR fortran/67367
        * gfortran.dg/read_dir.f90: New test. May fail on some platforms.

Added:
    trunk/gcc/testsuite/gfortran.dg/read_dir.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/67367] Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error
  2015-08-27  2:54 [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error urbanjost at comcast dot net
                   ` (5 preceding siblings ...)
  2015-08-29 15:53 ` jvdelisle at gcc dot gnu.org
@ 2015-08-31  0:14 ` jvdelisle at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-08-31  0:14 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

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

--- Comment #9 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Fixed on trunk.


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

end of thread, other threads:[~2015-08-31  0:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-27  2:54 [Bug fortran/67367] New: Program crashes on READ(IOSTAT=IOS, ...) on directory OPEN()ed without error urbanjost at comcast dot net
2015-08-27  4:18 ` [Bug fortran/67367] " jvdelisle at gcc dot gnu.org
2015-08-28 18:58 ` jvdelisle at gcc dot gnu.org
2015-08-28 22:05 ` sgk at troutmask dot apl.washington.edu
2015-08-29  0:16 ` jvdelisle at gcc dot gnu.org
2015-08-29 15:39 ` jvdelisle at gcc dot gnu.org
2015-08-29 15:53 ` jvdelisle at gcc dot gnu.org
2015-08-31  0:14 ` jvdelisle 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).