Bug 25756 - ICE on valid code with labels
ICE on valid code with labels
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.1.0
: P3 normal
: 4.1.0
Assigned To: kargl
: ice-on-valid-code
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2006-01-11 21:28 UTC by Bernhard Reutner-Fischer
Modified: 2006-02-10 23:21 UTC (History)
3 users (show)

See Also:
Host: i686-linux-gnu
Target: i686-linux-gnu
Build: i686-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-01-12 22:42:57


Attachments
testcase label_3.f90 (163 bytes, text/plain)
2006-01-11 21:32 UTC, Bernhard Reutner-Fischer
Details
testcase label_4.f90 (161 bytes, text/plain)
2006-01-11 21:33 UTC, Bernhard Reutner-Fischer
Details
testcase label_5.f90 (237 bytes, text/plain)
2006-01-11 21:34 UTC, Bernhard Reutner-Fischer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Reutner-Fischer 2006-01-11 21:28:14 UTC
attached label_3.f90, label_4.f90 and label_5.f90 ICE with
gcc version 4.1.0 20060111 (prerelease)

As this worked with g77, please make pr19292 depend on this.

Backtraces are provided for the sake of completeness.


$ gfortran-4.1-HEAD -v  -c -o /tmp/foo.o label_3.f90
 In file label_3.f90:4

1 ! { dg-warning "Ignoring statement label in empty statement" }
                                                               1
Warning: Ignoring statement label in empty statement at (1)
label_3.f90:5: internal compiler error: Segmentation fault

backtrace label_3.f90:
Program received signal SIGSEGV, Segmentation fault.
free_expr0 (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:141
141	  switch (e->expr_type)
(gdb) bt
#0  free_expr0 (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:141
#1  0x0805f161 in gfc_free_expr (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:230
#2  0x08090663 in gfc_free_namespace (ns=0x8564d30) at ../../../src/gcc-4.1/gcc/fortran/symbol.c:1504
#3  0x08090728 in gfc_symbol_done_2 () at ../../../src/gcc-4.1/gcc/fortran/symbol.c:2393
#4  0x080783f8 in gfc_done_2 () at ../../../src/gcc-4.1/gcc/fortran/misc.c:293
#5  0x0807f1fe in gfc_parse_file () at ../../../src/gcc-4.1/gcc/fortran/parse.c:2685
#6  0x08098593 in gfc_be_parse_file (set_yydebug=0) at ../../../src/gcc-4.1/gcc/fortran/f95-lang.c:286
#7  0x082cc358 in toplev_main (argc=11, argv=0xbfb72194) at ../../../src/gcc-4.1/gcc/toplev.c:990
#8  0x080ba0f2 in main (argc=8191, argv=0x29) at ../../../src/gcc-4.1/gcc/main.c:35

======================================================================
$ gfortran-4.1-HEAD -v  -c -o /tmp/foo.o label_4.f90
 In file label_4.f90:4

1 ! { dg-warning "Ignoring statement label in empty statement" }
                                                               1
Warning: Ignoring statement label in empty statement at (1)
label_4.f90:5: internal compiler error: Segmentation fault

backtrace label_4.f90:
Program received signal SIGSEGV, Segmentation fault.
free_expr0 (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:141
141	  switch (e->expr_type)
(gdb) bt
#0  free_expr0 (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:141
#1  0x0805f161 in gfc_free_expr (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:230
#2  0x08090663 in gfc_free_namespace (ns=0x8564d30) at ../../../src/gcc-4.1/gcc/fortran/symbol.c:1504
#3  0x08090728 in gfc_symbol_done_2 () at ../../../src/gcc-4.1/gcc/fortran/symbol.c:2393
#4  0x080783f8 in gfc_done_2 () at ../../../src/gcc-4.1/gcc/fortran/misc.c:293
#5  0x0807f1fe in gfc_parse_file () at ../../../src/gcc-4.1/gcc/fortran/parse.c:2685
#6  0x08098593 in gfc_be_parse_file (set_yydebug=0) at ../../../src/gcc-4.1/gcc/fortran/f95-lang.c:286
#7  0x082cc358 in toplev_main (argc=11, argv=0xbfd7a324) at ../../../src/gcc-4.1/gcc/toplev.c:990
#8  0x080ba0f2 in main (argc=8191, argv=0x29) at ../../../src/gcc-4.1/gcc/main.c:35

======================================================================
$ gfortran-4.1-HEAD -v  -c -o /tmp/foo.o label_5.f90
 In file label_5.f90:4

1 ! { dg-warning "Ignoring statement label in empty statement" }
                                                               1
Warning: Ignoring statement label in empty statement at (1)
 In file label_5.f90:5

1 ! { dg-warning "Ignoring statement label in empty statement" }
                                                               1
Warning: Ignoring statement label in empty statement at (1)
label_5.f90:6: internal compiler error: Segmentation fault


backtrace label_5.f90:
Program received signal SIGSEGV, Segmentation fault.
free_expr0 (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:141
141	  switch (e->expr_type)
(gdb) bt
#0  free_expr0 (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:141
#1  0x0805f161 in gfc_free_expr (e=0x12) at ../../../src/gcc-4.1/gcc/fortran/expr.c:230
#2  0x08090663 in gfc_free_namespace (ns=0x8564d90) at ../../../src/gcc-4.1/gcc/fortran/symbol.c:1504
#3  0x08090728 in gfc_symbol_done_2 () at ../../../src/gcc-4.1/gcc/fortran/symbol.c:2393
#4  0x080783f8 in gfc_done_2 () at ../../../src/gcc-4.1/gcc/fortran/misc.c:293
#5  0x0807f1fe in gfc_parse_file () at ../../../src/gcc-4.1/gcc/fortran/parse.c:2685
#6  0x08098593 in gfc_be_parse_file (set_yydebug=0) at ../../../src/gcc-4.1/gcc/fortran/f95-lang.c:286
#7  0x082cc358 in toplev_main (argc=11, argv=0xbf8d1e34) at ../../../src/gcc-4.1/gcc/toplev.c:990
#8  0x080ba0f2 in main (argc=8191, argv=0x29) at ../../../src/gcc-4.1/gcc/main.c:35
Comment 1 Bernhard Reutner-Fischer 2006-01-11 21:32:34 UTC
Created attachment 10626 [details]
testcase label_3.f90
Comment 2 Bernhard Reutner-Fischer 2006-01-11 21:33:35 UTC
Created attachment 10627 [details]
testcase label_4.f90
Comment 3 Bernhard Reutner-Fischer 2006-01-11 21:34:21 UTC
Created attachment 10628 [details]
testcase label_5.f90
Comment 4 Andrew Pinski 2006-01-11 21:41:00 UTC
Confirmed.  (well already via IRC).   Note you will not get this email for a while anyways.
Comment 5 kargl 2006-01-12 20:18:47 UTC
The following simple patch

Index: parse.c
===================================================================
--- parse.c     (revision 109606)
+++ parse.c     (working copy)
@@ -349,8 +349,10 @@ next_free (void)
            {
              gfc_warning_now
                ("Ignoring statement label in empty statement at %C");
+#if 0
              gfc_free_st_label (gfc_statement_label);
              gfc_statement_label = NULL;
+#endif
              return ST_NONE;
            }
        }

get rids of the ICE, but I don't understand why we have an ICE in first place.
The patch simply retains the labeled empty statement in the list of labels.
I haven't tested the patch beyond a simple program similar to those posted
by Bernhard.
Comment 6 Steve Kargl 2006-01-12 22:41:16 UTC
Subject: Re:  ICE on valid code with labels

On Thu, Jan 12, 2006 at 08:18:50PM -0000, kargl at gcc dot gnu dot org wrote:
> 
> get rids of the ICE, but I don't understand why we have an ICE in first place.
> The patch simply retains the labeled empty statement in the list of labels.

I peeked at the g95 source code, and now I have a better understanding on
why we get an ICE.  Ask yourself what happens when you delete the head
of a linked list but you do not update the head pointer and then you
want to start at head to delete the entire list.

Comment 7 kargl 2006-01-12 22:42:57 UTC
I have a patch.
Comment 8 kargl 2006-01-13 21:09:28 UTC
Subject: Bug 25756

Author: kargl
Date: Fri Jan 13 21:09:24 2006
New Revision: 109674

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109674
Log:
2006-01-13  Steven G. Kargl  <kargls@comcast.net>

        PR fortran/25756
        * symbol.c (gfc_free_st_label): Give variable meaningful name. Remove
        unneeded parenthesis. Fix-up the head of the list (2 lines gleaned
        from g95).

2006-01-13  Bernhard Fischer  <rep.nop@aon.at>

        PR fortran/25756
        * gfortran.dg/label_3.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/label_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 kargl 2006-01-13 21:10:11 UTC
Committed the fix to trunk.  I'll wait a few days for 4.1.
Comment 10 Bernhard Reutner-Fischer 2006-01-13 22:15:13 UTC
Should the warning be made consistent between fixed- and free form?

Both the gfc_warning vs. gfc_warning_now and the strings are not consistent.
Fixed Form has:
gfc_warning ("Statement label in blank line will be ignored at %C");

Free form does a warning_now like so:
gfc_warning_now ("Ignoring statement label in empty statement at %C");
Comment 11 Steve Kargl 2006-01-13 22:20:30 UTC
Subject: Re:  ICE on valid code with labels

On Fri, Jan 13, 2006 at 10:15:13PM -0000, aldot at gcc dot gnu dot org wrote:
> 
> Should the warning be made consistent between fixed- and free form?
> 

Yes.  Consider a change pre-approved for committing.

Comment 12 kargl 2006-02-10 23:20:14 UTC
Subject: Bug 25756

Author: kargl
Date: Fri Feb 10 23:20:10 2006
New Revision: 110856

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110856
Log:
2006-02-10  Steven G. Kargl  <kargls@comcast.net>

        PR fortran/25756
        * symbol.c (gfc_free_st_label): Give variable meaningful name. Remove
        unneeded parenthesis. Fix-up the head of the list (2 lines gleaned
        from g95).

2006-02-10  Bernhard Fischer  <rep.nop@aon.at>

        PR fortran/25756
        * gfortran.dg/label_3.f90: New test.




Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/label_3.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/symbol.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 13 kargl 2006-02-10 23:21:58 UTC
Fixed on 4.1, too.