Bug 30084 - [4.1 only] segmentation fault when compiling certain code
Summary: [4.1 only] segmentation fault when compiling certain code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Paul Thomas
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-12-06 14:33 UTC by Troban Trumsko
Modified: 2007-01-10 19:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0 4.3.0
Known to fail: 4.1.0
Last reconfirmed: 2006-12-20 12:24:19


Attachments
source files to crash gfortran (40.89 KB, application/octet-stream)
2006-12-06 14:36 UTC, Troban Trumsko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Troban Trumsko 2006-12-06 14:33:19 UTC
gfortran crashes when compiling teh attached code
(the same segmentation fault occures when compiling with 4.2.0 version of gfortran)

[trob@aqua] /tmp/gfortcrash $ gfortran -c kinds.f90 vamp_bundle.f90
vamp_bundle.f90:3166: 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.

[trob@aqua] /tmp/gfortcrash $ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/fxcoudert/gfortran_nightbuild/trunk/configure --prefix=/home/fxcoudert/gfortran_nightbuild/irun-20061130 --enable-languages=c,fortran --with-gmp=/home/fxcoudert/gfortran_nightbuild/software
Thread model: posix
gcc version 4.3.0 20061130 (experimental)
Comment 1 Troban Trumsko 2006-12-06 14:36:32 UTC
Created attachment 12754 [details]
source files to crash gfortran

unpack and execute
 gfortran -c kinds.f90 vamp_bundle.f90
to reproduce segmentation violation
Comment 2 kargls 2006-12-06 17:37:50 UTC
Reduced testcase:

module tao_random_numbers
  integer, dimension(10) :: s_buffer
  integer :: s_last = size (s_buffer)
end module tao_random_numbers

module linalg
  contains
  function diag (a) result (d)
    real, dimension(:,:), intent(in) :: a
    real, dimension(min(size(a,dim=1),size(a,dim=2))) :: d
    integer :: i
    do i = 1, min(size(a, dim = 1), size(a, dim = 2))
       d(i) = a(i,i)
    end do
  end function diag
end module linalg

module vamp_rest
  use tao_random_numbers
  use linalg
end module vamp_rest
Comment 3 Tobias Burnus 2006-12-06 22:39:44 UTC
Backtrace:
0x000000000043abf3 in mio_symtree_ref (stp=0xe2b070) at gcc/fortran/module.c:2199
2199          if ((*stp)->n.sym && check_unique_name((*stp)->name))
#1  0x000000000043b526 in mio_expr (ep=0xe2b028) at gcc/fortran/module.c:2637

Even more reduced test case. Note that changing the order of "use" suppresses the ICE. (ICE occurs with 4.1, 4.2, 4.3)


module tao_random_numbers
  integer, dimension(10) :: s_buffer
  integer :: s_last = size (s_buffer)
end module tao_random_numbers

module linalg
  contains
  function diag (a) result (d)
    real, dimension(:), intent(in) :: a
    real, dimension(size(a)) :: d
    d = 0.0
  end function diag
end module linalg

module vamp_rest
  use tao_random_numbers
  use linalg
end module vamp_rest
Comment 4 Paul Thomas 2006-12-07 16:29:47 UTC
(In reply to comment #3)

It appears to be some wierdness with size => replace size with kind and the ICE goes away too.

Paul
Comment 5 Paul Thomas 2006-12-20 12:24:19 UTC
Note the patch was submitted 19/12 but the tracking system seems to have lost it.

Paul
Comment 6 Tobias Burnus 2006-12-21 16:18:03 UTC
> Note the patch was submitted 19/12 but the tracking system seems to have lost
> it.
http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01326.html
Comment 7 Paul Thomas 2006-12-22 20:49:13 UTC
Subject: Bug 30084

Author: pault
Date: Fri Dec 22 20:49:00 2006
New Revision: 120155

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

	PR fortran/25818
	* trans-array.c (gfc_trans_g77_array): If the variable is
	optional or not always present, make the statement conditional
	on presence of the argument.
	* gfortran.h : Add symbol_attribute not_always_present.
	* resolve.c (check_argument_lists): New function to check if
	arguments are not present in all entries.

	PR fortran/30084
	* module.c (mio_component_ref): Move treatment of unique name
	variables, during output, to fix_mio_expr.
	(fix_mio_expr): New function that fixes defective expressions
	before they are written to the module file.
	(mio_expr): Call the new function.
	(resolve_entries): Call check_argument_lists.

2006-12-22  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25818
	* gfortran.dg/entry_array_specs_2.f: New test.

	PR fortran/30084
	* gfortran.dg/nested_modules_6.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/entry_array_specs_2.f
    trunk/gcc/testsuite/gfortran.dg/nested_modules_6.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Paul Thomas 2007-01-03 21:27:29 UTC
Subject: Bug 30084

Author: pault
Date: Wed Jan  3 21:27:17 2007
New Revision: 120399

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120399
Log:
2007-01-03  Paul Thomas  <pault@gcc.gnu.org>

	Backport from trunk

	PR fortran/25818
	* trans-array.c (gfc_trans_g77_array): If the variable is
	optional or not always present, make the statement conditional
	on presence of the argument.
	* gfortran.h : Add symbol_attribute not_always_present.
	* resolve.c (check_argument_lists): New function to check if
	arguments are not present in all entries.

	PR fortran/30084
	* module.c (mio_component_ref): Move treatment of unique name
	variables, during output, to fix_mio_expr.
	(fix_mio_expr): New function that fixes defective expressions
	before they are written to the module file.
	(mio_expr): Call the new function.
	(resolve_entries): Call check_argument_lists.

2007-01-03  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25818
	* gfortran.dg/entry_array_specs_2.f: New test.

	PR fortran/30084
	* gfortran.dg/nested_modules_6.f90: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/entry_array_specs_2.f
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/nested_modules_6.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/gfortran.h
    branches/gcc-4_2-branch/gcc/fortran/module.c
    branches/gcc-4_2-branch/gcc/fortran/resolve.c
    branches/gcc-4_2-branch/gcc/fortran/trans-array.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 9 Paul Thomas 2007-01-03 21:30:37 UTC
Fixed on trunk and 4.2

Paul