Bug 40662 - gfortran 4.5 segfaults when specific FORMAT is invoked twice
Summary: gfortran 4.5 segfaults when specific FORMAT is invoked twice
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-06 17:58 UTC by Michael Richmond
Modified: 2009-07-09 02:01 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Richmond 2009-07-06 17:58:43 UTC
When I compile and run the following program under gfortran 4.5 I get a segfault. It does not segfault under gfortran 4.3 or 4.4. The problem occurs on any platform.

      PROGRAM astap
      ARLXCA = 0.0
      WRITE(6,40) ARLXCA
      WRITE(6,40) ARLXCA
40    FORMAT(T4,"ARLXCA = ",1PG13.6,T27,"ARLXCC = ",G13.6,T53,
     .            "ATMPCA = ",G13.6,T79,"ATMPCC = ",G13.6,T105,
     .            "BACKUP = ",G13.6,/,
     .         T4,"CSGFAC = ",G13.6,T27,"CSGMAX = ",G13.6,T53,
     .            "CSGMIN = ",G13.6,T79,"DRLXCA = ",G13.6,T105,
     .            "DRLXCC = ",G13.6,/,
     .         T4,"DTIMEH = ",G13.6,T27,"DTIMEI = ",G13.6,T53,
     .            "DTIMEL = ",G13.6,T79,"DTIMEU = ",G13.6,T105,
     .            "DTMPCA = ",G13.6,/,
     .         T4,"DTMPCC = ",G13.6,T27,"EBALNA = ",G13.6,T53,
     .            "EBALNC = ",G13.6,T79,"EBALSA = ",G13.6,T105,
     .            "EBALSC = ",G13.6)
      END PROGRAM astap
Comment 1 Dominique d'Humieres 2009-07-06 18:07:50 UTC
This seems to be fixed by the patch in comment #33 of pr40330.
Comment 2 Jerry DeLisle 2009-07-06 18:12:20 UTC
Yes indeed it is fixed with my patch of this morning. This is the reduced test case we can use for the test suite.

Thanks for the report Michael!
Comment 3 kargls 2009-07-06 18:18:05 UTC
(In reply to comment #1)
> This seems to be fixed by the patch in comment #33 of pr40330.
> 

Removing the 1st occurrence of T27 in the format is sufficient to
remove the segfault.
Comment 4 Jerry DeLisle 2009-07-09 01:20:44 UTC
Subject: Bug 40662

Author: jvdelisle
Date: Thu Jul  9 01:20:23 2009
New Revision: 149398

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149398
Log:
2009-07-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/40330
	PR libfortran/40662
	* io/io.h (st_parameter_dt): Define format_not_saved bit used to signal
	whether the parsed format data was previously saved. Used to determine
	if the current format data should be freed or not.
	* io/transfer.c (st_read_done): Use the format_not_saved bit.
	(st_write_done): Likewise.
	* io/format.c (parse_format_list): Add boolean pointer to arg list. This
	pointer is used to return status to the caller regarding whether it is
	safe to cache the parsed format data.  Currently, if a FMT_STRING token
	is encounetered, it is not safe to cache. Also, added a local boolean
	variable to hold this information as recursive calls to
	parse_format_list are made.  Remove previous save_format logic.
	(parse_format): Do not use the format caching facility if the current
	unit is an internal unit or if it is not safe to save parsed format
	data.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/format.c
    trunk/libgfortran/io/io.h
    trunk/libgfortran/io/transfer.c

Comment 5 Jerry DeLisle 2009-07-09 01:55:01 UTC
Subject: Bug 40662

Author: jvdelisle
Date: Thu Jul  9 01:54:47 2009
New Revision: 149399

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149399
Log:
2009-07-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/40330
	PR libfortran/40662
	* gfortran.dg/fmt_cache_1.f: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/fmt_cache_1.f
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 6 Jerry DeLisle 2009-07-09 02:01:36 UTC
Fixed on trunk.
Comment 7 hjl@gcc.gnu.org 2009-07-23 17:51:47 UTC
Subject: Bug 40662

Author: hjl
Date: Thu Jul 23 17:50:56 2009
New Revision: 150020

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150020
Log:
2009-07-23  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2009-07-22  Richard Guenther  <rguenther@suse.de>

	PR c++/40799
	* g++.dg/lookup/using21.C: New testcase.

	2009-07-19  Jan Hubicka  <jh@suse.cz>

	PR tree-optimization/40676
	* gcc.c-torture/compile/pr40676.c: New testcase.

	2009-07-15  Richard Guenther  <rguenther@suse.de>

	PR middle-end/40753
	* gcc.c-torture/compile/pr40753.c: New testcase.

	2009-07-14  Dodji Seketeli  <dodji@redhat.com>

	PR debug/40705
	* g++.dg/debug/dwarf2/typedef1.C: New test.

	PR c++/40357
	* g++.dg/other/typedef3.C: New test.

	2009-07-10  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/40496
	* g++.dg/opt/pr40496.C: New testcase.

	2009-07-09  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/40692
	* gcc.c-torture/compile/pr40692.c: New test.

	2009-07-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/40330
	PR libfortran/40662
	* gfortran.dg/fmt_cache_1.f: New test.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/debug/dwarf2/typedef1.C
      - copied unchanged from r150018, trunk/gcc/testsuite/g++.dg/debug/dwarf2/typedef1.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/using21.C
      - copied unchanged from r150018, trunk/gcc/testsuite/g++.dg/lookup/using21.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/opt/pr40496.C
      - copied unchanged from r150018, trunk/gcc/testsuite/g++.dg/opt/pr40496.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/typedef3.C
      - copied unchanged from r150018, trunk/gcc/testsuite/g++.dg/other/typedef3.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr40676.c
      - copied unchanged from r150018, trunk/gcc/testsuite/gcc.c-torture/compile/pr40676.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr40692.c
      - copied unchanged from r150018, trunk/gcc/testsuite/gcc.c-torture/compile/pr40692.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr40753.c
      - copied unchanged from r150018, trunk/gcc/testsuite/gcc.c-torture/compile/pr40753.c
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/fmt_cache_1.f
      - copied unchanged from r150018, trunk/gcc/testsuite/gfortran.dg/fmt_cache_1.f
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog