Bug 56674 - [4.8/4.9/5/6 Regression] ICE in check_sym_interfaces
Summary: [4.8/4.9/5/6 Regression] ICE in check_sym_interfaces
Status: RESOLVED DUPLICATE of bug 59016
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.9.0
: P4 normal
Target Milestone: 4.8.5
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2013-03-21 12:26 UTC by Joost VandeVondele
Modified: 2015-04-14 12:42 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-11-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2013-03-21 12:26:46 UTC
The following invalid testcase produces and ICE with current trunk.

> cat bug.f90 
MODULE kinds
  INTEGER, PARAMETER :: dp=8,int_8=8
END MODULE 
MODULE realspace_grid_types
  USE kinds,                           ONLY: dp, int_8
  PUBLIC :: realspace_grid_type,&
            realspace_grid_input_type
  END TYPE realspace_grid_desc_type
  TYPE realspace_grid_desc_p_type
     TYPE(realspace_grid_desc_type), POINTER :: rs_desc
  END TYPE realspace_grid_desc_p_type
CONTAINS
  SUBROUTINE rs_grid_create_descriptor ( desc, pw_grid, input_settings, error)
    TYPE(realspace_grid_input_type), &
    IF ( pw_grid % para % mode == PW_MODE_LOCAL ) THEN
  END SUBROUTINE
END MODULE realspace_grid_types


> gfortran -v  bug.f90 
Driving: gfortran -v bug.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/data/vjoost/gnu/gcc_trunk/install/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/data/vjoost/gnu/gcc_trunk/install --enable-languages=c,c++,fortran --disable-multilib --enable-plugins --enable-lto --disable-bootstrap
Thread model: posix
gcc version 4.9.0 20130321 (experimental) [trunk revision 196847] (GCC) 
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /data/vjoost/gnu/gcc_trunk/install/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/f951 bug.f90 -quiet -dumpbase bug.f90 -mtune=generic -march=x86-64 -auxbase bug -version -fintrinsic-modules-path /data/vjoost/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/finclude -o /tmp/ccaTm8lw.s
GNU Fortran (GCC) version 4.9.0 20130321 (experimental) [trunk revision 196847] (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.7.2 20120816 (prerelease) [gcc-4_7-branch revision 190437], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU Fortran (GCC) version 4.9.0 20130321 (experimental) [trunk revision 196847] (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.7.2 20120816 (prerelease) [gcc-4_7-branch revision 190437], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
bug.f90:8.5:

  END TYPE realspace_grid_desc_type
     1
Error: Expecting END MODULE statement at (1)
bug.f90:14.35:

    TYPE(realspace_grid_input_type), &
                                   1
Error: Derived type 'realspace_grid_input_type' at (1) is being used before it is defined
bug.f90:10.55:

     TYPE(realspace_grid_desc_type), POINTER :: rs_desc
                                                       1
Error: The pointer component 'rs_desc' of 'realspace_grid_desc_p_type' at (1) is a type that has not been declared
f951: internal compiler error: Segmentation fault
0x994a0f crash_signal
	../../gcc/gcc/toplev.c:332
0x55650b show_locus
	../../gcc/gcc/fortran/error.c:310
0x556d77 error_print
	../../gcc/gcc/fortran/error.c:666
0x5573a8 gfc_error(char const*, ...)
	../../gcc/gcc/fortran/error.c:961
0x55fda7 check_interface0
	../../gcc/gcc/fortran/interface.c:1469
0x562194 check_sym_interfaces
	../../gcc/gcc/fortran/interface.c:1581
0x5c8023 do_traverse_symtree
	../../gcc/gcc/fortran/symbol.c:3575
0x562279 gfc_check_interfaces(gfc_namespace*)
	../../gcc/gcc/fortran/interface.c:1691
0x5b3bbb resolve_types
	../../gcc/gcc/fortran/resolve.c:14915
0x5a7773 gfc_resolve
	../../gcc/gcc/fortran/resolve.c:14999
0x5a7773 gfc_resolve(gfc_namespace*)
	../../gcc/gcc/fortran/resolve.c:14987
0x59d287 gfc_parse_file()
	../../gcc/gcc/fortran/parse.c:4602
0x5da8d5 gfc_be_parse_file
	../../gcc/gcc/fortran/f95-lang.c:189
Please submit a full bug report,
Comment 1 Joost VandeVondele 2013-03-21 12:32:40 UTC
Appears to work fine with 4.6.3, goes wrong with 4.7.2
Comment 2 Tobias Burnus 2013-03-21 14:46:48 UTC
Some debugging seems to indicate that it is due to the implementation of the constructor, i.e. DT name == generic name.

The problem is that for
  iface->sym
"sym" contains undefined memory (presumably created and later freed), which fails for iface->sym->name.

"iface" is:
resolve.c:      for (iface = sym->generic; iface; iface = iface->next)
and sym->name is "realspace_grid_input_type".

Thus, it seems as if the DT has been deleted but not the entry in the generic list.
Comment 3 Richard Biener 2013-04-11 07:59:12 UTC
GCC 4.7.3 is being released, adjusting target milestone.
Comment 4 Dominique d'Humieres 2013-06-20 18:12:56 UTC
Still present at revision 200247.
Comment 5 Dominique d'Humieres 2013-12-26 12:58:09 UTC
This appeared at r181425.
Comment 6 Dominique d'Humieres 2014-01-06 22:26:59 UTC
> This appeared at r181425.

This revision also gives pr57129.
Comment 7 Dominique d'Humieres 2014-04-06 09:04:24 UTC
Slightly reduced test

MODULE realspace_grid_types
  PUBLIC :: realspace_grid_input_type
CONTAINS
  SUBROUTINE rs_grid_create_descriptor ( )
    TYPE(realspace_grid_input_type),
  END SUBROUTINE
END MODULE realspace_grid_types

pr56674_red.f90:5.35:

    TYPE(realspace_grid_input_type),
                                   1
Error: Derived type 'realspace_grid_input_type' at (1) is being used before it is defined
f951: internal compiler error: Segmentation fault: 11
Comment 8 Richard Biener 2014-06-12 13:45:39 UTC
The 4.7 branch is being closed, moving target milestone to 4.8.4.
Comment 9 Jakub Jelinek 2014-12-19 13:35:31 UTC
GCC 4.8.4 has been released.
Comment 10 Mikael Morin 2015-04-10 11:30:24 UTC
Author: mikael
Date: Fri Apr 10 11:29:53 2015
New Revision: 221972

URL: https://gcc.gnu.org/viewcvs?rev=221972&root=gcc&view=rev
Log:
	PR fortran/56674
	PR fortran/58813
	PR fortran/59016
	PR fortran/59024
fortran/
	* symbol.c (save_symbol_data, gfc_save_symbol_data): Rename the
	former to the latter and make it non-static.  Update callers.
	* gfortran.h (gfc_save_symbol_data): New prototype.
	* decl.c (gfc_match_decl_type_spec): Call 'gfc_save_symbol_data'
	before modifying symbols 'sym' and 'dt_sym'.
testsuite/
	* gfortran.dg/used_types_27.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/used_types_27.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
Comment 11 Mikael Morin 2015-04-14 09:18:46 UTC
Author: mikael
Date: Tue Apr 14 09:18:15 2015
New Revision: 222078

URL: https://gcc.gnu.org/viewcvs?rev=222078&root=gcc&view=rev
Log:
	PR fortran/56674
	PR fortran/58813
	PR fortran/59016
	PR fortran/59024
fortran/
	* symbol.c (save_symbol_data, gfc_save_symbol_data): Rename the
	former to the latter and make it non-static.  Update callers.
	* gfortran.h (gfc_save_symbol_data): New prototype.
	* decl.c (gfc_match_decl_type_spec): Call 'gfc_save_symbol_data'
	before modifying symbols 'sym' and 'dt_sym'.
testsuite/
	* gfortran.dg/used_types_27.f90: New.


Added:
    branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/used_types_27.f90
Modified:
    branches/gcc-4_9-branch/gcc/fortran/ChangeLog
    branches/gcc-4_9-branch/gcc/fortran/decl.c
    branches/gcc-4_9-branch/gcc/fortran/gfortran.h
    branches/gcc-4_9-branch/gcc/fortran/symbol.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
Comment 12 Mikael Morin 2015-04-14 12:24:02 UTC
Author: mikael
Date: Tue Apr 14 12:23:30 2015
New Revision: 222086

URL: https://gcc.gnu.org/viewcvs?rev=222086&root=gcc&view=rev
Log:
	PR fortran/56674
	PR fortran/58813
	PR fortran/59016
	PR fortran/59024
fortran/
	* symbol.c (save_symbol_data, gfc_save_symbol_data): Rename the
	former to the latter and make it non-static.  Update callers.
	* gfortran.h (gfc_save_symbol_data): New prototype.
	* decl.c (gfc_match_decl_type_spec): Call 'gfc_save_symbol_data'
	before modifying symbols 'sym' and 'dt_sym'.
testsuite/
	* gfortran.dg/used_types_27.f90: New.


Added:
    branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/used_types_27.f90
Modified:
    branches/gcc-4_8-branch/gcc/fortran/ChangeLog
    branches/gcc-4_8-branch/gcc/fortran/decl.c
    branches/gcc-4_8-branch/gcc/fortran/gfortran.h
    branches/gcc-4_8-branch/gcc/fortran/symbol.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Comment 13 Mikael Morin 2015-04-14 12:42:49 UTC
Dup.

*** This bug has been marked as a duplicate of bug 59016 ***