public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
@ 2015-07-13 16:30 rainer@emrich-ebersheim.de
  2015-07-13 17:14 ` [Bug libfortran/66861] " rainer@emrich-ebersheim.de
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: rainer@emrich-ebersheim.de @ 2015-07-13 16:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66861
           Summary: [5/6 Regression] Segmentation fault in
                    gcc/testsuite/gfortran.dg/streamio_5.f90
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rainer@emrich-ebersheim.de
  Target Milestone: ---

Since gcc-5 I get a lot of fortran testsuite failures. Most of these with IO
involved and causing a timeout. This an regression. For trunk I'm not sure. I
haven't had the time to build trunk yet. But I expect it has the same issue.

$ gfortran.exe -v
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=D:\opt\devel\gnu\gcc\MINGW_NT\x86_64-w64-mingw32\mingw-w64-runtime-trunk-svn\gcc-5.1.1\bin\gfortran.exe
COLLECT_LTO_WRAPPER=d:/opt/devel/gnu/gcc/mingw_nt/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.1.1/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.1/lto-wrapper.exe
Ziel: x86_64-w64-mingw32
Konfiguriert mit:
../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.1.1/configure
--prefix=/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.1.1
--with-gnu-as
--with-as=/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.1.1/bin/as
--with-gnu-ld
--with-ld=/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.1.1/bin/ld
--build=x86_64-w64-mingw32 --enable-threads=posix
--enable-languages=c,ada,c++,fortran,java,lto,objc,obj-c++
--with-gmp-include=/opt/devel/SCRATCH/tmp.kzqcdNeWDQ/install/include
--with-gmp-lib=/opt/devel/SCRATCH/tmp.kzqcdNeWDQ/install/lib64
--with-mpfr-include=/opt/devel/SCRATCH/tmp.kzqcdNeWDQ/install/include
--with-mpfr-lib=/opt/devel/SCRATCH/tmp.kzqcdNeWDQ/install/lib64
--with-mpc-include=/opt/devel/SCRATCH/tmp.kzqcdNeWDQ/install/include
--with-mpc-lib=/opt/devel/SCRATCH/tmp.kzqcdNeWDQ/install/lib64
--with-isl-include=/opt/devel/SCRATCH/tmp.kzqcdNeWDQ/install/include
--with-isl-lib=/opt/devel/SCRATCH/tmp.kzqcdNeWDQ/install/lib64
--with-local-prefix=/opt/devel/tec/devel/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.1.1
--enable-libgomp --enable-fully-dynamic-string --disable-multilib
--enable-checking=release --disable-werror --with-sysroot=/x86_64-w64-trunk
Thread-Modell: posix
gcc-Version 5.1.1 20150712 [gcc-5-branch revision 225722] (GCC)



gfortran.exe -O2
/opt/devel/gnu/src/gcc/gcc-5-svn/gcc/testsuite/gfortran.dg/streamio_5.f90

$ gdb a.exe
GNU gdb (GDB) 7.9
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.exe...done.
(gdb) run
Starting program: D:\msys64\home\rainer\temp\a.exe
[New Thread 4676.0x529c]

Program received signal SIGSEGV, Segmentation fault.
0x000007fefd675960 in strcmp () from C:\Windows\system32\msvcrt.dll
(gdb) where
#0  0x000007fefd675960 in strcmp () from C:\Windows\system32\msvcrt.dll
#1  0x000000006f6eaa94 in find_file0 (u=<optimized out>,
    id=id@entry=162129586587129478, path=path@entry=0x786300 "teststream")
    at
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.1.1/libgfortran/io/unix.c:1573
#2  0x000000006f6c9209 in _gfortrani_find_file (file=<optimized out>,
    file_len=<optimized out>)
    at
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.1.1/libgfortran/io/unix.c:1615
#3  0x000000006f6cf385 in _gfortrani_new_unit (opp=opp@entry=0x22fc10,
    u=u@entry=0x785ff0, flags=flags@entry=0x22fb80)
    at
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.1.1/libgfortran/io/open.c:486
#4  0x000000006f6bd922 in already_open (flags=<optimized out>,
    u=<optimized out>, opp=<optimized out>)
    at
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.1.1/libgfortran/io/open.c:672
#5  _gfortran_st_open (opp=0x22fc10)
    at
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.1.1/libgfortran/io/open.c:837
#6  0x000000000040179c in MAIN__ ()
#7  0x0000000000403080 in main ()
(gdb) exit
Undefined command: "exit".  Try "help".
(gdb) quit
A debugging session is active.

        Inferior 1 [process 4676] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]


So, the crash appears in msvcrt.dll. But the call looks suspicious:
find_file0 (u=<optimized out>, id=id@entry=162129586587129478,
path=path@entry=0x786300 "teststream")

Using gcc-4.9.3 is fine, no issue here.


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
@ 2015-07-13 17:14 ` rainer@emrich-ebersheim.de
  2015-07-13 18:56 ` jb at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rainer@emrich-ebersheim.de @ 2015-07-13 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Rainer Emrich <rainer@emrich-ebersheim.de> ---
I suspect the following commit causing the issue:

215307:

File size: 43008 byte(s)

PR libfortran/62768 Handle filenames with embedded null characters.

testsuite ChangeLog:

2014-09-17  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/62768
        * gfortran.dg/filename_null.f90: New test.

libgfortran ChangeLog:

2014-09-17  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/62768
        * io/io.h (gfc_unit): Store C string for the filename.
        * io/close.c (st_close): Use gfc_unit.filename.
        * io/inquire.c (inquire_via_unit): Likewise.
        * io/open.c (new_unit): Likewise.
        (already_open): Likewise, unlink file before freeing filename.
        * io/unit.c (init_units): Likewise.
        (close_unit_1): Likewise.
        (filename_from_unit): Likewise.
        * io/unix.c (compare_file_filename): Likewise.
        (find_file0): Likewise.
        (delete_file): Likewise.


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
  2015-07-13 17:14 ` [Bug libfortran/66861] " rainer@emrich-ebersheim.de
@ 2015-07-13 18:56 ` jb at gcc dot gnu.org
  2015-07-13 21:49 ` rainer@emrich-ebersheim.de
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu.org @ 2015-07-13 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Or rather, also fixing another similar potential issue, you might instead want
to test this:

diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index e5fc6e1..a1ce9a3 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1525,7 +1525,10 @@ compare_file_filename (gfc_unit *u, const char *name,
int len)
       goto done;
     }
 # endif
-  ret = (strcmp(path, u->filename) == 0);
+  if (u->filename)
+    ret = (strcmp(path, u->filename) == 0);
+  else
+    ret = 0;
 #endif
  done:
   free (path);
@@ -1570,7 +1573,7 @@ find_file0 (gfc_unit *u, FIND_FILE0_DECL)
     }
   else
 # endif
-    if (strcmp (u->filename, path) == 0)
+    if (u->filename && strcmp (u->filename, path) == 0)
       return u;
 #endif


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
  2015-07-13 17:14 ` [Bug libfortran/66861] " rainer@emrich-ebersheim.de
  2015-07-13 18:56 ` jb at gcc dot gnu.org
@ 2015-07-13 21:49 ` rainer@emrich-ebersheim.de
  2015-07-14  8:18 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rainer@emrich-ebersheim.de @ 2015-07-13 21:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Rainer Emrich <rainer@emrich-ebersheim.de> ---
Am 13.07.2015 um 20:56 schrieb jb at gcc dot gnu.org:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66861
> 
> --- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> --- Or rather,
> also fixing another similar potential issue, you might instead want to test
> this:
> 
> diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index
> e5fc6e1..a1ce9a3 100644 --- a/libgfortran/io/unix.c +++
> b/libgfortran/io/unix.c @@ -1525,7 +1525,10 @@ compare_file_filename
> (gfc_unit *u, const char *name, int len) goto done; } # endif -  ret =
> (strcmp(path, u->filename) == 0); +  if (u->filename) +    ret =
> (strcmp(path, u->filename) == 0); +  else +    ret = 0; #endif done: free
> (path); @@ -1570,7 +1573,7 @@ find_file0 (gfc_unit *u, FIND_FILE0_DECL) } 
> else # endif -    if (strcmp (u->filename, path) == 0) +    if (u->filename
> && strcmp (u->filename, path) == 0) return u; #endif
> 
I will test this tomorrow.


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
                   ` (2 preceding siblings ...)
  2015-07-13 21:49 ` rainer@emrich-ebersheim.de
@ 2015-07-14  8:18 ` rguenth at gcc dot gnu.org
  2015-07-14 12:30 ` rainer@emrich-ebersheim.de
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-14  8:18 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |5.2


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
                   ` (3 preceding siblings ...)
  2015-07-14  8:18 ` rguenth at gcc dot gnu.org
@ 2015-07-14 12:30 ` rainer@emrich-ebersheim.de
  2015-07-14 20:26 ` jb at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rainer@emrich-ebersheim.de @ 2015-07-14 12:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Rainer Emrich <rainer@emrich-ebersheim.de> ---
(In reply to Janne Blomqvist from comment #3)
> Or rather, also fixing another similar potential issue, you might instead
> want to test this:
> 
> diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
> index e5fc6e1..a1ce9a3 100644
> --- a/libgfortran/io/unix.c
> +++ b/libgfortran/io/unix.c
> @@ -1525,7 +1525,10 @@ compare_file_filename (gfc_unit *u, const char *name,
> int len)
>        goto done;
>      }
>  # endif
> -  ret = (strcmp(path, u->filename) == 0);
> +  if (u->filename)
> +    ret = (strcmp(path, u->filename) == 0);
> +  else
> +    ret = 0;
>  #endif
>   done:
>    free (path);
> @@ -1570,7 +1573,7 @@ find_file0 (gfc_unit *u, FIND_FILE0_DECL)
>      }
>    else
>  # endif
> -    if (strcmp (u->filename, path) == 0)
> +    if (u->filename && strcmp (u->filename, path) == 0)
>        return u;
>  #endif

This solves the issue!

Richard set target milestone to 5.2. So I suppose this should go into trunk and
the gcc-5 branch.


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
                   ` (4 preceding siblings ...)
  2015-07-14 12:30 ` rainer@emrich-ebersheim.de
@ 2015-07-14 20:26 ` jb at gcc dot gnu.org
  2015-07-14 20:29 ` jb at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu.org @ 2015-07-14 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Tue Jul 14 20:26:06 2015
New Revision: 225788

URL: https://gcc.gnu.org/viewcvs?rev=225788&root=gcc&view=rev
Log:
PR 66861 Fix null pointer crash on mingw.

2015-07-14  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/66861
        * io/unix.c (compare_file_filename): Verify that u->filename is
        non-NULL before strcmp.
        (find_file0): Likewise.

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


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
                   ` (5 preceding siblings ...)
  2015-07-14 20:26 ` jb at gcc dot gnu.org
@ 2015-07-14 20:29 ` jb at gcc dot gnu.org
  2015-07-15  7:01 ` jb at gcc dot gnu.org
  2015-07-15  7:10 ` jb at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu.org @ 2015-07-14 20:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Fixed on trunk. I'm not sure if the milestone thing implies an Ok to commit to
the gcc-5 branch, as we're already on 5.2 rc2, I'll ask explicitly for an Ok.


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
                   ` (6 preceding siblings ...)
  2015-07-14 20:29 ` jb at gcc dot gnu.org
@ 2015-07-15  7:01 ` jb at gcc dot gnu.org
  2015-07-15  7:10 ` jb at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu.org @ 2015-07-15  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Wed Jul 15 07:00:23 2015
New Revision: 225805

URL: https://gcc.gnu.org/viewcvs?rev=225805&root=gcc&view=rev
Log:
PR 66861 Fix null pointer crash on mingw.

2015-07-15  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/66861
        * io/unix.c (compare_file_filename): Verify that u->filename is
        non-NULL before strcmp.
        (find_file0): Likewise.

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


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

* [Bug libfortran/66861] [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90
  2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
                   ` (7 preceding siblings ...)
  2015-07-15  7:01 ` jb at gcc dot gnu.org
@ 2015-07-15  7:10 ` jb at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jb at gcc dot gnu.org @ 2015-07-15  7:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #9 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Fixed on gcc-5 branch as well, release manager approval at
https://gcc.gnu.org/ml/gcc/2015-07/msg00184.html .

Closing as fixed, thanks Rainer for reporting the issue and testing!


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

end of thread, other threads:[~2015-07-15  7:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-13 16:30 [Bug libfortran/66861] New: [5/6 Regression] Segmentation fault in gcc/testsuite/gfortran.dg/streamio_5.f90 rainer@emrich-ebersheim.de
2015-07-13 17:14 ` [Bug libfortran/66861] " rainer@emrich-ebersheim.de
2015-07-13 18:56 ` jb at gcc dot gnu.org
2015-07-13 21:49 ` rainer@emrich-ebersheim.de
2015-07-14  8:18 ` rguenth at gcc dot gnu.org
2015-07-14 12:30 ` rainer@emrich-ebersheim.de
2015-07-14 20:26 ` jb at gcc dot gnu.org
2015-07-14 20:29 ` jb at gcc dot gnu.org
2015-07-15  7:01 ` jb at gcc dot gnu.org
2015-07-15  7:10 ` 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).