[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-10-18 Thread tkoenig at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

Thomas Koenig  changed:

   What|Removed |Added

 CC||tkoenig at gcc dot gnu.org

--- Comment #19 from Thomas Koenig  ---
Fixed for 10.2. 9.4 and 11.1 will have the fix in.

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-10-18 Thread longb at cray dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

--- Comment #18 from Bill Long  ---
Original submitted asking about the GCC version that has / will have the fix.

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-28 Thread anlauf at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|REOPENED|RESOLVED

--- Comment #17 from anlauf at gcc dot gnu.org ---
Should be fixed now.

Thanks, Rainer, for precisely pointing at the latent issue.

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-28 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

--- Comment #16 from CVS Commits  ---
The releases/gcc-9 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:0d607ecbf125551513e182a181ca9c6e25dc7609

commit r9-8633-g0d607ecbf125551513e182a181ca9c6e25dc7609
Author: Harald Anlauf 
Date:   Thu May 28 21:53:17 2020 +0200

PR fortran/95104 - Segfault on a legal WAIT statement

The initial commit for this PR uncovered a latent issue with unit locking
in the Fortran run-time library.  Add check for valid unit.

2020-05-28  Harald Anlauf  

libgfortran/
PR libfortran/95104
* io/unit.c (unlock_unit): Guard by check for NULL pointer.

(cherry picked from commit 6ce3d791dfcba469e709935aba5743640f7d4959)

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-28 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

--- Comment #15 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:e1396ee72e68cc8fba99ce986f2910cd39e335b8

commit r10-8202-ge1396ee72e68cc8fba99ce986f2910cd39e335b8
Author: Harald Anlauf 
Date:   Thu May 28 21:53:17 2020 +0200

PR fortran/95104 - Segfault on a legal WAIT statement

The initial commit for this PR uncovered a latent issue with unit locking
in the Fortran run-time library.  Add check for valid unit.

2020-05-28  Harald Anlauf  

libgfortran/
PR libfortran/95104
* io/unit.c (unlock_unit): Guard by check for NULL pointer.

(cherry picked from commit 6ce3d791dfcba469e709935aba5743640f7d4959)

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-28 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

--- Comment #14 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:6ce3d791dfcba469e709935aba5743640f7d4959

commit r11-704-g6ce3d791dfcba469e709935aba5743640f7d4959
Author: Harald Anlauf 
Date:   Thu May 28 21:53:17 2020 +0200

PR fortran/95104 - Segfault on a legal WAIT statement

The initial commit for this PR uncovered a latent issue with unit locking
in the Fortran run-time library.  Add check for valid unit.

2020-05-28  Harald Anlauf  

libgfortran/
PR libfortran/95104
* io/unit.c (unlock_unit): Guard by check for NULL pointer.

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-28 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

Rainer Orth  changed:

   What|Removed |Added

 Resolution|FIXED   |---
 Status|RESOLVED|REOPENED
 CC||ro at gcc dot gnu.org

--- Comment #13 from Rainer Orth  ---
The new testcase FAILs on (at least): Solaris (both sparc and x86):

+FAIL: gfortran.dg/pr95104.f90   -O0  execution test
+FAIL: gfortran.dg/pr95104.f90   -O1  execution test
+FAIL: gfortran.dg/pr95104.f90   -O2  execution test
+FAIL: gfortran.dg/pr95104.f90   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions  execution test
+FAIL: gfortran.dg/pr95104.f90   -O3 -g  execution test
+FAIL: gfortran.dg/pr95104.f90   -Os  execution test

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

After recompiling libgfortran with -g3 -O0, I see

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0xfec554a8 in pthread_mutex_unlock () from /lib/libc.so.1
(gdb) where
#0  0xfec554a8 in pthread_mutex_unlock () from /lib/libc.so.1
#1  0xff1287bc in __gthread_mutex_unlock (__mutex=0xc8)
at ../libgcc/gthr-default.h:779
#2  0xff12a178 in _gfortrani_unlock_unit (u=0x0)
at /vol/gcc/src/hg/master/local/libgfortran/io/unit.c:771
#3  0xff127ffc in _gfortran_st_wait_async (wtp=0xffbfe750)
at /vol/gcc/src/hg/master/local/libgfortran/io/transfer.c:4511
#4  0x00010eac in test ()
at /vol/gcc/src/hg/master/local/gcc/testsuite/gfortran.dg/pr95104.f90:5
#5  0x00010f40 in main (argc=1, argv=0xffbfe992)
at /vol/gcc/src/hg/master/local/gcc/testsuite/gfortran.dg/pr95104.f90:8
#6  0x00010c74 in _start ()

#3  0xff127ffc in _gfortran_st_wait_async (wtp=0xffbfe750)
at /vol/gcc/src/hg/master/local/libgfortran/io/transfer.c:4511
4511  unlock_unit (u);
(gdb) p u
$2 = (gfc_unit *) 0x0

Either the unlock_unit needs to be guarded by if (u) or moved into the 
if (ASYNC_IO && u ...) check.

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-27 Thread anlauf at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #12 from anlauf at gcc dot gnu.org ---
Fixed on master for gcc-11, and backported to 10- and 9-branches.

Thanks for the report!

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-27 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

--- Comment #11 from CVS Commits  ---
The releases/gcc-9 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:6f64bc18a664e1d003120cfa8508cb5fe06fa7ad

commit r9-8629-g6f64bc18a664e1d003120cfa8508cb5fe06fa7ad
Author: Harald Anlauf 
Date:   Tue May 26 23:29:52 2020 +0200

PR fortran/95104 - Segfault on a legal WAIT statement

Referencing a unit in a WAIT statement that has not been opened before
resulted in a NULL pointer dereference.  Check for this condition.

2020-05-26  Harald Anlauf  

libgfortran/
PR libfortran/95104
* io/transfer.c (st_wait_async): Do not dereference NULL pointer.

gcc/testsuite/
PR libfortran/95104
* gfortran.dg/pr95104.f90: New test.

Co-Authored-By: Steven G. Kargl  
(cherry picked from commit 56f03cd12be26828788a27f6f3c250041a958e45)

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-27 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

--- Comment #10 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:50cd4503e59f29e379d0515c48e67d0658ee4562

commit r10-8193-g50cd4503e59f29e379d0515c48e67d0658ee4562
Author: Harald Anlauf 
Date:   Tue May 26 23:29:52 2020 +0200

PR fortran/95104 - Segfault on a legal WAIT statement

Referencing a unit in a WAIT statement that has not been opened before
resulted in a NULL pointer dereference.  Check for this condition.

2020-05-26  Harald Anlauf  

libgfortran/
PR libfortran/95104
* io/transfer.c (st_wait_async): Do not dereference NULL pointer.

gcc/testsuite/
PR libfortran/95104
* gfortran.dg/pr95104.f90: New test.

Co-Authored-By: Steven G. Kargl  
(cherry picked from commit 56f03cd12be26828788a27f6f3c250041a958e45)

[Bug libfortran/95104] [9/10 Regression] Segfault on a legal WAIT statement

2020-05-26 Thread anlauf at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

Summary|[9/10/11 Regression]|[9/10 Regression] Segfault
   |Segfault on a legal WAIT|on a legal WAIT statement
   |statement   |
   Assignee|unassigned at gcc dot gnu.org  |anlauf at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #9 from anlauf at gcc dot gnu.org ---
Fixed on master for gcc-11.

Backports pending.