Bug 60774 - f951: internal compiler error: Segmentation fault: 11
Summary: f951: internal compiler error: Segmentation fault: 11
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.2
: P3 normal
Target Milestone: 7.0
Assignee: kargls
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2014-04-07 03:25 UTC by Kevin Cahill
Modified: 2016-08-22 18:28 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-04-08 00:00:00


Attachments
A fortran program I wrote. (3.09 KB, text/plain)
2014-04-07 03:25 UTC, Kevin Cahill
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Cahill 2014-04-07 03:25:37 UTC
Created attachment 32555 [details]
A fortran program I wrote.

gfortran -Wall -O3 -o $1 $2
energy.f95:180.3:

123 
   1
Warning: Ignoring statement label in empty statement at (1)
f951: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 1 Dominique d'Humieres 2014-04-08 19:34:20 UTC
Confirmed from 4.5 to 4.9 (trunk). Compiling the following reduced tests

program energy  
  implicit none ! all dble  
  integer(kind=4)::ns  ! size of spatial lattice
  integer(kind=4)::i,j,k,l
  integer(kind=4),allocatable::back(:,:) ! works up to 20,10
  integer(kind=4)::di,index
  doubleprecision,allocatable::sumffi(:)
  doubleprecision,allocatable::f(:,:,:,:) ! the dimensionless field
  go to 123
  do di = 0, ns/2 
     sumffi(di) = sumffi(di) + f(i,j,k,l)*f(back(i,di),j,k,l)
  end do
123 
contains
  function T(i,j,k,l,iu,ju,ku,lu,id,jd,kd,ld) ! only what depends on ijkl
    doubleprecision::T
    integer(kind=4)::i,j,k,l,iu,id,ju,jd,ku,kd,lu,ld
    T = f(i,j,k,l)*( f(i,j,k,l) - f(iu,j,k,l) - f(id,j,k,l) )
  end function T
end program energy

gives and ICE with 4.5, the error

pr60774_red.f90:13.3:

123 
   1
Warning: Ignoring statement label in empty statement at (1)
pr60774_red.f90:9.11:

  go to 123
           1
Error: Label 123 referenced at (1) is never defined

with 4.6 and 4.7, and

pr60774_red.f90:13.3:

123 
   1
Warning: Ignoring statement label in empty statement at (1)
<During initialization>

Error: Label 1119913824 referenced at (1) is never defined

with 4.8 and 4.9 (and an ICE with my working tree!-).
Comment 2 Dominique d'Humieres 2014-04-09 09:06:04 UTC
Reduced test giving an ICE with a clean trunk (r209224)

program energy  
  implicit none ! all dble  
  integer(kind=4)::ns  ! size of spatial lattice
  integer(kind=4)::nt  ! size of temporal lattice; nt >= ns
  integer(kind=4)::i,j,k,l!,iu,id,ju,jd,ku,kd,lu,ld
  integer(kind=4),allocatable::back(:,:) ! works up to 20,10
  integer(kind=4)::di
  doubleprecision,allocatable::sumffi(:)
  doubleprecision,allocatable::f(:,:,:,:) ! the dimensionless field
  ! potential energy; first something I did in an earlier paper
  nt = 10
  ns = 2
  allocate( f(nt,ns,ns,ns), back(ns,0:10) )
  allocate( sumffi(0:nt/2))
  go to 123
  do di = 0, ns/2 
     sumffi(di) = sumffi(di) + f(i,j,k,l)*f(back(i,di),j,k,l)
  end do
123 
contains
  function T(i,j,k,l,iu,ju,ku,lu,id,jd,kd,ld) ! only what depends on ijkl
    doubleprecision::T
    integer(kind=4)::i,j,k,l,iu,id,ju,jd,ku,kd,lu,ld
    T = f(i,j,k,l)*( f(i,j,k,l) - f(iu,j,k,l) - f(id,j,k,l) )
  end function T
end program energy

The backtrace is

  * frame #0: 0x00007fff91e76866 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff989c935c libsystem_pthread.dylib`pthread_kill + 92
    frame #2: 0x00007fff98740b1a libsystem_c.dylib`abort + 125
    frame #3: 0x0000000100bd7978 f951`linemap_lookup(set=0x0000000141d49000, line=<unavailable>) + 456 at line-map.c:709
    frame #4: 0x0000000100bd79dc f951`linemap_macro_loc_to_exp_point(set=0x0000000141d49000, location=33570, original_map=0x00007fff5fbfedf8) + 76 at line-map.c:1181
    frame #5: 0x0000000100bbf59e f951`expand_location_1(loc=33570, expansion_point_p=<unavailable>) + 126 at input.c:164
    frame #6: 0x0000000100bc039e f951`expand_location(loc=<unavailable>) + 14 at input.c:724
    frame #7: 0x000000010002e188 f951`show_locus(c1=-1350314028, c2=-1, loc=<unavailable>) + 88 at error.c:355
    frame #8: 0x000000010002ed3e f951`error_print(type=0x0000000100cd1751, format0=0x0000000100ce34a8, argp=<unavailable>) + 2286 at error.c:476
    frame #9: 0x000000010002f90e f951`gfc_error(gmsgid=<unavailable>) + 446 at error.c:1003
    frame #10: 0x000000010008e4c9 f951`resolve_code(code=0x0000000141f08e40, ns=0x0000000143023c00) + 9241 at resolve.c:9828
    frame #11: 0x000000010008f8a4 f951`resolve_codes(ns=<unavailable>) + 308 at resolve.c:14610
    frame #12: 0x000000010008f99d f951`gfc_resolve(ns=0x0000000143023c00) + 61 at resolve.c:14638
    frame #13: 0x0000000100079fab f951`gfc_parse_file() [inlined] resolve_all_program_units(gfc_global_ns_list=0x0000000143023c00) + 71 at parse.c:4468
    frame #14: 0x0000000100079f64 f951`gfc_parse_file() + 1364
    frame #15: 0x00000001000bc276 f951`gfc_be_parse_file + 38 at f95-lang.c:188
    frame #16: 0x000000010086a287 f951`compile_file + 39 at toplev.c:548
    frame #17: 0x000000010086c7a4 f951`toplev_main(argc=2, argv=0x00007fff5fbff4a0) + 3284 at toplev.c:1914
Comment 3 Bud Davis 2014-06-30 02:48:24 UTC
reduced a bit further.


program energy  
  go to 123
123 
contains
function T(i,j,k,l,iu,ju,ku,lu,id,jd,kd,ld) 
 end function T
end program energy


the label is "123"
make it "123 "

and the segfault does not happen.

(random strange thing seen when reducing it)
Comment 4 Kevin Cahill 2014-06-30 03:20:12 UTC
Thank you.
Best wishes,
Kevin

Kevin Cahill
Professor of Physics & Astronomy
Physics Dept. 1919 Lomas NE, MSC 07 4220 
University of New Mexico 
Albuquerque, NM 87131-0001

kevinecahill@gmail.com   cahill@unm.edu   505 205 5448  
Until 14 July, I am at KIAS in Seoul  +82 (0) 10-2930-5448



On Jun 30, 2014, at 11:48 AM, bdavis at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60774
> 
> Bud Davis <bdavis at gcc dot gnu.org> changed:
> 
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                 CC|                            |bdavis at gcc dot gnu.org
> 
> --- Comment #3 from Bud Davis <bdavis at gcc dot gnu.org> ---
> reduced a bit further.
> 
> 
> program energy  
>  go to 123
> 123 
> contains
> function T(i,j,k,l,iu,ju,ku,lu,id,jd,kd,ld) 
> end function T
> end program energy
> 
> 
> the label is "123"
> make it "123 "
> 
> and the segfault does not happen.
> 
> (random strange thing seen when reducing it)
> 
> -- 
> You are receiving this mail because:
> You reported the bug.
Comment 5 Bud Davis 2014-08-24 20:19:01 UTC
Index: gcc/gcc/fortran/parse.c
===================================================================
--- gcc/gcc/fortran/parse.c	(revision 214408)
+++ gcc/gcc/fortran/parse.c	(working copy)
@@ -868,8 +868,6 @@
 	    {
 	      gfc_warning_now ("Ignoring statement label in empty statement "
 			       "at %L", &label_locus);
-	      gfc_free_st_label (gfc_statement_label);
-	      gfc_statement_label = NULL;
 	      return ST_NONE;
 	    }
 	}

Looks very promising.
Comment 6 kargls 2016-08-22 18:24:15 UTC
Author: kargl
Date: Mon Aug 22 18:23:43 2016
New Revision: 239668

URL: https://gcc.gnu.org/viewcvs?rev=239668&root=gcc&view=rev
Log:
2016-08-22  Steven G. Kargl  <kargl@gcc.gnu.org>
	    Bud Davis  <jmdavis@link.com>

	PR fortran/60774
	* parse.c (next_free,next_fixed): Issue error for statement label
	without a statement.

2016-08-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/60774
	* gfortran.dg/empty_label.f: Adjust test for new error message.
	* gfortran.dg/empty_label.f90: Ditto.
	* gfortran.dg/empty_label_typedecl.f90: Ditto.
	* gfortran.dg/label_3.f90: Deleted (redundant with empty_label.f90).
	* gfortran.dg/warnings_are_errors_1.f90: Remove invalid statement label.

Removed:
    trunk/gcc/testsuite/gfortran.dg/label_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/parse.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/empty_label.f
    trunk/gcc/testsuite/gfortran.dg/empty_label.f90
    trunk/gcc/testsuite/gfortran.dg/empty_label_typedecl.f90
    trunk/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90
Comment 7 kargls 2016-08-22 18:28:19 UTC
Fixed on trunk.