[Bug libfortran/64770] [5 Regression] Segmentation fault when opening a file with status="new" and the file exists.
jb at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jan 24 21:33:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64770
Janne Blomqvist <jb at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2015-01-24
Assignee|unassigned at gcc dot gnu.org |jb at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Confirmed.
Running the testcase under gdb gives the following backtrace:
#0 0x0000000000446a5a in strlen ()
#1 0x000000000044699e in strdup ()
#2 0x0000000000404eac in _gfortrani_filename_from_unit (n=<optimized out>) at
../../../trunk-git/libgfortran/io/unit.c:833
#3 0x000000000040266f in _gfortrani_show_locus (cmp=0x7fffffffd2d0) at
../../../trunk-git/libgfortran/runtime/error.c:266
#4 0x0000000000402c10 in _gfortrani_generate_error
(cmp=cmp@entry=0x7fffffffd2d0, family=family@entry=5000,
message=message@entry=0x6f7b60 'File \'test.dat\' already exists\000') at
../../../trunk-git/libgfortran/runtime/error.c:561
#5 0x0000000000403d43 in _gfortrani_new_unit (opp=opp@entry=0x7fffffffd2d0,
u=u@entry=0x6f7ca0, flags=flags@entry=0x7fffffffd270)
at ../../../trunk-git/libgfortran/io/open.c:533
#6 0x0000000000403fde in already_open (flags=<optimized out>, u=<optimized
out>, opp=<optimized out>) at ../../../trunk-git/libgfortran/io/open.c:694
#7 _gfortran_st_open (opp=0x7fffffffd2d0) at
../../../trunk-git/libgfortran/io/open.c:859
#8 0x0000000000401175 in pr64770 () at pr64770-open_new_segv.f90:4
#9 0x00000000004011e4 in main (argc=1, argv=0x7fffffffd929) at
pr64770-open_new_segv.f90:7
#10 0x000000000042562c in __libc_start_main ()
#11 0x0000000000400fe7 in _start ()
unit.c:833 is
/* Get the filename. */
if (u != NULL)
return strdup (u->filename); // <- Line 833
else
return (char *) NULL;
I suspect changing the test to
if (u != NULL && u->filename != NULL)
should fix it.
More information about the Gcc-bugs
mailing list