Bug 48788 - [4.6/4.7 Regression] ICE: SIGSEGV in resolve_global_procedure (resolve.c:2190) on invalid (?) fortran code
[4.6/4.7 Regression] ICE: SIGSEGV in resolve_global_procedure (resolve.c:2190...
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.7.0
: P3 normal
: 4.6.1
Assigned To: Not yet assigned to anyone
: ice-on-invalid-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-27 10:28 UTC by Zdenek Sojka
Modified: 2011-04-28 18:44 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail: 4.6.1, 4.7.0
Last reconfirmed:


Attachments
reduced testcase (108 bytes, text/plain)
2011-04-27 10:28 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2011-04-27 10:28:02 UTC
Created attachment 24113 [details]
reduced testcase

Compiler output:
$ gfortran testcase.f90
testcase.f90:3.31:

  character(4), external :: foo
                               1
Error: Return type mismatch of function 'foo' at (1) (CHARACTER(1)/REAL(4))
==3307== Invalid read of size 8
==3307==    at 0x55C8D2: resolve_global_procedure (resolve.c:2190)
==3307==    by 0x560A8D: gfc_resolve_expr (resolve.c:3005)
==3307==    by 0x5684C9: resolve_code (resolve.c:9028)
==3307==    by 0x56A84E: resolve_codes (resolve.c:13614)
==3307==    by 0x55C32B: gfc_resolve (resolve.c:13641)
==3307==    by 0x5522BA: gfc_parse_file (parse.c:4200)
==3307==    by 0x58B175: gfc_be_parse_file (f95-lang.c:250)
==3307==    by 0x95E2BB: toplev_main (toplev.c:579)
==3307==    by 0x644AB6C: (below main) (in /lib64/libc-2.11.3.so)
==3307==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==3307== 
f951: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Tested revisions:
r172960 - crash
4.6 r172337 - crash
4.5 r172337 - code is accepted
Comment 1 Tobias Burnus 2011-04-27 11:33:21 UTC
2189    if (sym->ts.type == BT_CHARACTER && sym->attr.if_source != IFSRC_IFBODY
2190        && def_sym->ts.u.cl->length != NULL)

As def_sym is not BT_CHARACTER, dereferencing def_sym->ts.u.cl fails ...
Comment 2 Tobias Burnus 2011-04-27 20:32:26 UTC
Author: burnus
Date: Wed Apr 27 20:32:21 2011
New Revision: 173048

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173048
Log:
2011-04-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/48788
        * resolve.c (resolve_global_procedure): Error recovery -
        avoid segfault for (non)character-returning functions.

2011-04-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/48788
        * gfortran.dg/whole_file_34.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/whole_file_34.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Tobias Burnus 2011-04-28 18:43:19 UTC
Author: burnus
Date: Thu Apr 28 18:43:16 2011
New Revision: 173126

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173126
Log:
2011-04-28  Tobias Burnus  <burnus@net-b.de>

        PR fortran/48788
        * resolve.c (resolve_global_procedure): Error recovery -
        avoid segfault for (non)character-returning functions.


2011-04-28  Tobias Burnus  <burnus@net-b.de>

        PR fortran/48788
        * gfortran.dg/whole_file_34.f90: New.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/whole_file_34.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/resolve.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 4 Tobias Burnus 2011-04-28 18:44:13 UTC
FIXED on the trunk - and on the 4.6 branch.

Thanks for the report!