Bug 24866 - internal compiler error
Summary: internal compiler error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2005-11-14 23:59 UTC by Uttam Pawar
Modified: 2006-08-30 05:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-07-24 21:30:23


Attachments
A fix for the PR and a testsuite entry (713 bytes, patch)
2006-08-19 16:54 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Uttam Pawar 2005-11-14 23:59:48 UTC
Following program cause internal compiler error. I wasn't sure if this has been seen/filed before.

$ cat test_module.f90
module test_module
 contains
   subroutine sub_module(str)
     external :: str
   end subroutine sub_module
   subroutine str()
   end subroutine str
end module test_module

$ gfortran -v -c test_module.f90
test_module.f90:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Using built-in specs.
Target: powerpc64-linux
Configured with: /home/gccbuild/gcc_trunk_anonsvn/trunk/configure --prefix=/opt/gcc-nightly/trunk-20051110 --build=powerpc64-linux --host=powerpc64-linux --target=powerpc64-linux --with-cpu=default32 --with-as=/opt/gcc-nightly/trunk-20051110/bin/as --with-ld=/opt/gcc-nightly/trunk-20051110/bin/ld --enable-threads=posix --enable-shared --enable-__cxa_atexit --enable-languages=c,c++,f95,java,objc,obj-c++ --enable-checking --with-mpfr=/opt/gcc-nightly/trunk-20051110
Thread model: posix
gcc version 4.1.0 20051110 (experimental)
 /home/gcc-nightly/trunk-20051110/bin/../libexec/gcc/powerpc64-linux/4.1.0/f951 test_module.f90 -quiet -dumpbase test_module.f90 -auxbase test_module -version -o /tmp/ccUJBiuf.s
GNU F95 version 4.1.0 20051110 (experimental) (powerpc64-linux)
        compiled by GNU C version 4.1.0 20051110 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096

backtrace is

142                   if (sym->result->ts.type == BT_UNKNOWN)
(gdb) p sym
$1 = (gfc_symbol *) 0x1075be20
(gdb) p sym->result
$2 = (struct gfc_symbol *) 0x0
(gdb) bt
#0  resolve_formal_arglist (proc=0x1075bda0) at /home/gccbuild/gcc_trunk_anonsvn/trunk/gcc/fortran/resolve.c:142
#1  0x10059c70 in traverse_ns (st=0x107408b0, func=0x1004a310 <find_arglists>)
    at /home/gccbuild/gcc_trunk_anonsvn/trunk/gcc/fortran/symbol.c:2416
#2  0x1004f008 in gfc_resolve (ns=0x1075b670) at /home/gccbuild/gcc_trunk_anonsvn/trunk/gcc/fortran/resolve.c:267
#3  0x24000482 in ?? ()
#4  0x10045244 in gfc_parse_file () at /home/gccbuild/gcc_trunk_anonsvn/trunk/gcc/fortran/parse.c:2664
#5  0x10064e04 in gfc_be_parse_file (set_yydebug=Variable "set_yydebug" is not available.
) at /home/gccbuild/gcc_trunk_anonsvn/trunk/gcc/fortran/f95-lang.c:286
#6  0x10340a5c in toplev_main (argc=Variable "argc" is not available.
) at /home/gccbuild/gcc_trunk_anonsvn/trunk/gcc/toplev.c:990
#7  0x10092540 in main (argc=Variable "argc" is not available.
) at /home/gccbuild/gcc_trunk_anonsvn/trunk/gcc/main.c:35
Comment 1 Andrew Pinski 2005-11-15 04:21:39 UTC
Confirmed, maybe related to PR 20892.
Comment 2 Andrew Pinski 2006-01-03 17:07:10 UTC
Not PPC specific.
Comment 3 Andrew Pinski 2006-01-27 20:46:25 UTC
I now get:
end module test_module
                     1
 Internal Error at (1):
 write_symbol(): bad module symbol 'UCS-2BE//'
Comment 4 Francois-Xavier Coudert 2006-05-21 20:37:51 UTC
Why is this code invalid? (the keywork ice-on-invalid-code is set)

No error is reported with Sun, Intel and g95.
Comment 5 Francois-Xavier Coudert 2006-07-24 21:30:23 UTC
This one is still here, segfaulting or giving incorrect error message depending on the optimization level used for building the front-end.

We enter write_symbol1 with p->u.rsym->sym.name = "sub_module", we go to p->right->u.rsym->sym.name which is "str" and then p->right->left->u.rsym->sym.name is "UCS-2BE//", which suddenly doesn't make sense :)

I know you're on vacation, Paul, but I think what looks troubling to us would look trivial to you, friendly as you are with the module code in gfortran!
Comment 6 Paul Thomas 2006-08-19 05:49:24 UTC
> I know you're on vacation, Paul, but I think what looks troubling to us would
> look trivial to you, friendly as you are with the module code in gfortran!
> 
I'll have a look today - I am in the midst of a triage of the fortran PRs and this comes out as one of the "straight to the operating theatre" category.  Offhand, I think that it is a primary.c/decl.c problem rather than a module.c but I'll let you know.

Paul
Comment 7 Paul Thomas 2006-08-19 12:32:06 UTC
Yes, the problem is as I thought; rename the dummy and the external procedure, say to str1, and the module compiles fine.  It also compiles if the order of the subroutines is changed.  These are symptomatic of the symbol for str() being made available to sub_module by host association and then having the external attribute added to it.

This is confirmed by comparing the parse trees for the two different orders for the subroutines.  In the case that fails, we have

          procedure name = sub_module
          symtree: str  Ambig 0 from namespace test_module
          symtree: sub_module  Ambig 0 from namespace test_module

whilst the one that succeeds has

          symtree: sub_module  Ambig 0 from namespace test_module
          symtree: str  Ambig 0
          symbol str (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC EXTERNAL DUMMY)

I am not sure where this screw up occurs but am looking very closely at decl.c(attr_decl1).

Paul


Comment 8 Paul Thomas 2006-08-19 16:54:52 UTC
Created attachment 12098 [details]
A fix for the PR and a testsuite entry

The problem turned out to be in parse.c(gfc_fixup_sibling_symbols), which insisted on fixing up procedures to refer to the parent namespace version even if the contained symbol is a dummy.  The fix is simple; just a modification to an if statement.

Paul
Comment 9 patchapp@dberlin.org 2006-08-20 06:01:06 UTC
Subject: Bug number PR24866

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00711.html
Comment 10 patchapp@dberlin.org 2006-08-20 07:45:11 UTC
Subject: Bug number PR24866

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00719.html
Comment 11 Paul Thomas 2006-08-30 05:19:00 UTC
Subject: Bug 24866

Author: pault
Date: Wed Aug 30 05:18:36 2006
New Revision: 116578

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116578
Log:
2006-08-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/28885
	REGRESSION FIX
	* trans-expr.c (gfc_conv_aliased_arg): Ensure that the temp
	declaration is retained for INTENT(OUT) arguments.

	PR fortran/28873
	REGRESSION FIX
	PR fortran/20067
	* resolve.c (resolve_generic_f): Make error message more
	comprehensible.
	(resolve_generic_s): Restructure search for specific procedures
	to be similar to resolve_generic_f and change to similar error
	message.  Ensure that symbol reference is refreshed, in case
	the search produces a NULL.
	(resolve_specific_s): Restructure search, as above and as
	resolve_specific_f. Ensure that symbol reference is refreshed,
	in case the search produces a NULL.

	PR fortran/25077
	PR fortran/25102
	* interface.c (check_operator_interface): Throw error if the
	interface assignment tries to change intrinsic type assigments
	or has less than two arguments.  Also, it is an error if an
	interface operator contains an alternate return.

	PR fortran/24866
	* parse.c (gfc_fixup_sibling_symbols): Do not modify the symbol
	if it is a dummy in the contained namespace.


2006-08-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/28885
	* gfortran.dg/aliasing_dummy_2.f90: New test.

	PR fortran/20067
	* gfortran.dg/generic_5.f90: Change error message.

	PR fortran/28873
	* gfortran.dg/generic_6.f90: New test.

	PR fortran/25077
	* gfortran.dg/redefined_intrinsic_assignment.f90: New test.

	PR fortran/25102
	* gfortran.dg/invalid_interface_assignment.f90: New test.

	PR fortran/24866
	* gfortran.dg/module_proc_external_dummy.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/aliasing_dummy_2.f90
    trunk/gcc/testsuite/gfortran.dg/generic_6.f90
    trunk/gcc/testsuite/gfortran.dg/invalid_interface_assignment.f90
    trunk/gcc/testsuite/gfortran.dg/module_proc_external_dummy.f90
    trunk/gcc/testsuite/gfortran.dg/redefined_intrinsic_assignment.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/parse.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/generic_5.f90

Comment 12 Paul Thomas 2006-08-30 05:19:59 UTC
Subject: Bug 24866

Author: pault
Date: Wed Aug 30 05:19:34 2006
New Revision: 116579

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116579
Log:
2006-08-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/28885
	REGRESSION FIX
	* trans-expr.c (gfc_conv_aliased_arg): Ensure that the temp
	declaration is retained for INTENT(OUT) arguments.

	PR fortran/28873
	REGRESSION FIX
	PR fortran/20067
	* resolve.c (resolve_generic_f): Make error message more
	comprehensible.
	(resolve_generic_s): Restructure search for specific procedures
	to be similar to resolve_generic_f and change to similar error
	message.  Ensure that symbol reference is refreshed, in case
	the search produces a NULL.
	(resolve_specific_s): Restructure search, as above and as
	resolve_specific_f. Ensure that symbol reference is refreshed,
	in case the search produces a NULL.

	PR fortran/25077
	PR fortran/25102
	* interface.c (check_operator_interface): Throw error if the
	interface assignment tries to change intrinsic type assigments
	or has less than two arguments.  Also, it is an error if an
	interface operator contains an alternate return.

	PR fortran/24866
	* parse.c (gfc_fixup_sibling_symbols): Do not modify the symbol
	if it is a dummy in the contained namespace.


2006-08-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/28885
	* gfortran.dg/aliasing_dummy_2.f90: New test.

	PR fortran/20067
	* gfortran.dg/generic_5.f90: Change error message.

	PR fortran/28873
	* gfortran.dg/generic_6.f90: New test.

	PR fortran/25077
	* gfortran.dg/redefined_intrinsic_assignment.f90: New test.

	PR fortran/25102
	* gfortran.dg/invalid_interface_assignment.f90: New test.

	PR fortran/24866
	* gfortran.dg/module_proc_external_dummy.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/aliasing_dummy_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/generic_6.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/invalid_interface_assignment.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/module_proc_external_dummy.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/redefined_intrinsic_assignment.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/interface.c
    branches/gcc-4_1-branch/gcc/fortran/parse.c
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/generic_5.f90

Comment 13 Paul Thomas 2006-08-30 05:33:00 UTC
Fixed on trunk and 4.1

Paul