https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95104
Rainer Orth <ro at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |--- Status|RESOLVED |REOPENED CC| |ro at gcc dot gnu.org --- Comment #13 from Rainer Orth <ro at gcc dot gnu.org> --- 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.