Bug 17612 - ICE in gfortran
Summary: ICE in gfortran
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored, patch
: 15494 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-22 15:52 UTC by Paolo Giannozzi
Modified: 2004-10-15 17:15 UTC (History)
4 users (show)

See Also:
Host: i686 Linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-09-22 16:14:38


Attachments
First attempt at fixing this PR (911 bytes, patch)
2004-09-24 17:55 UTC, Tobias Schlüter
Details | Diff
Updated patch which fixes the bug (1.01 KB, patch)
2004-09-25 13:35 UTC, Tobias Schlüter
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo Giannozzi 2004-09-22 15:52:00 UTC
Daily gfortran build downloaded on 22 sep. 2004 for 
Linux i686 
 
$ gfc --version 
GNU Fortran 95 (GCC 4.0.0 20040922 (experimental)) 
Copyright (C) 2003 Free Software Foundation, Inc. 
 
$ gfc -c bug.f90 
bug.f90: In function 'nullify_pseudo_upf': 
bug.f90:76: internal compiler error: Segmentation fault 
 
$ cat bug.f90 
      MODULE pseudo_types 
 
        IMPLICIT NONE 
        INTEGER, PARAMETER :: dbl = selected_real_kind(14,200) 
 
        SAVE 
 
        TYPE pseudo_upf 
          CHARACTER(LEN=80):: generated   !  
          CHARACTER(LEN=80):: date_author ! Misc info 
          CHARACTER(LEN=80):: comment     ! 
          CHARACTER(LEN=2) :: psd       ! Element label 
          CHARACTER(LEN=20) :: typ      ! Pseudo type ( NC or US ) 
          LOGICAL  :: tvanp             ! .true. if Ultrasoft 
          LOGICAL :: nlcc               ! Non linear core corrections 
          CHARACTER(LEN=20) :: dft      ! Exch-Corr type 
          REAL(dbl) :: zp               ! z valence 
          REAL(dbl) :: etotps           ! total energy 
          REAL(dbl) :: ecutwfc          ! suggested cut-off for wfc 
          REAL(dbl) :: ecutrho          ! suggested cut-off for rho 
          LOGICAL :: has_so             ! if .true. includes spin-orbit 
          REAL(dbl) :: xmin             ! the minimum x of the linear mesh 
          REAL(dbl) :: rmax             ! the maximum radius of the mesh 
          REAL(dbl) :: zmesh            ! the nuclear charge used for mesh 
          REAL(dbl) :: dx               ! the deltax of the linear mesh 
          INTEGER, POINTER :: nn(:)      ! nn(nwfc) 
          REAL(dbl), POINTER :: rcut(:)  ! cut-off radius(nwfc) 
          REAL(dbl), POINTER :: rcutus(:)! cut-off ultrasoft radius (nwfc) 
          REAL(dbl), POINTER :: epseu(:) ! energy (nwfc) 
          REAL(dbl), POINTER :: jchi(:)  ! jchi(nwfc) 
          REAL(dbl), POINTER :: jjj(:)   ! jjj(nbeta) 
 
          INTEGER :: nv                 ! UPF file version number 
          INTEGER :: lmax               ! maximum angular momentum component 
          INTEGER :: mesh               ! number of point in the radial mesh 
          INTEGER :: nwfc               ! number of wavefunctions 
          INTEGER :: nbeta              ! number of projectors 
          CHARACTER(LEN=2), POINTER :: els(:)  ! els(nwfc) 
          INTEGER, POINTER :: lchi(:)   ! lchi(nwfc) 
          REAL(dbl), POINTER :: oc(:)   ! oc(nwfc) 
          REAL(dbl), POINTER :: r(:)    ! r(mesh) 
          REAL(dbl), POINTER :: rab(:)  ! rab(mesh) 
          REAL(dbl), POINTER :: rho_atc(:) ! rho_atc(mesh) 
          REAL(dbl), POINTER :: vloc(:)    ! vloc(mesh) 
          INTEGER, POINTER :: lll(:)       ! lll(nbeta) 
          INTEGER, POINTER :: kkbeta(:)    ! kkbeta(nbeta) 
          REAL(dbl), POINTER :: beta(:,:)  ! beta(mesh,nbeta) 
          INTEGER :: nd 
          REAL(dbl), POINTER :: dion(:,:)  ! dion(nbeta,nbeta) 
          INTEGER :: nqf 
          INTEGER :: nqlc 
          REAL(dbl), POINTER :: rinner(:)  ! rinner(0:2*lmax) 
          REAL(dbl), POINTER :: qqq(:,:)   ! qqq(nbeta,nbeta) 
          REAL(dbl), POINTER :: qfunc(:,:,:) ! qfunc(mesh,nbeta,nbeta) 
          REAL(dbl), POINTER :: qfcoef(:,:,:,:) ! 
          REAL(dbl), POINTER :: chi(:,:) !  chi(mesh,nwfc) 
          REAL(dbl), POINTER :: rho_at(:) !  rho_at(mesh) 
        END TYPE 
 
      CONTAINS 
 
        SUBROUTINE nullify_pseudo_upf( upf ) 
          TYPE( pseudo_upf ), INTENT(INOUT) :: upf 
          NULLIFY( upf%els, upf%lchi, upf%jchi, upf%oc ) 
          NULLIFY( upf%r, upf%rab )   
          NULLIFY( upf%rho_atc, upf%vloc )   
          NULLIFY( upf%nn, upf%rcut) 
          NULLIFY( upf%rcutus, upf%epseu) 
          NULLIFY( upf%lll, upf%jjj, upf%kkbeta, upf%beta, upf%dion )   
          NULLIFY( upf%rinner, upf%qqq, upf%qfunc, upf%qfcoef )   
          NULLIFY( upf%chi )   
          NULLIFY( upf%rho_at )   
          RETURN 
        END SUBROUTINE 
 
      END MODULE pseudo_types
Comment 1 Tobias Schlüter 2004-09-22 15:58:44 UTC
Confirmed. Backtrce:
Program received signal SIGSEGV, Segmentation fault.
0x0809bcd3 in gfc_conv_expr_descriptor (se=0xfef53c5c, expr=0x96354e0,
    ss=0x9639950) at ../../gcc-clean/gcc/fortran/trans-array.c:3566
3566                se->string_length = expr->symtree->n.sym->ts.cl->backend_decl;
(gdb) bt
#0  0x0809bcd3 in gfc_conv_expr_descriptor (se=0xfef53c5c, expr=0x96354e0,
    ss=0x9639950) at ../../gcc-clean/gcc/fortran/trans-array.c:3566
#1  0x080a66c3 in gfc_trans_pointer_assignment (expr1=0x96354e0,
    expr2=0x96356e0) at ../../gcc-clean/gcc/fortran/trans-expr.c:1898
#2  0x080a6849 in gfc_trans_pointer_assign (code=0xfef53c5c)
    at ../../gcc-clean/gcc/fortran/trans-expr.c:1858
#3  0x08093cba in gfc_trans_code (code=0x9635f20)
    at ../../gcc-clean/gcc/fortran/trans.c:505
#4  0x080a2550 in gfc_generate_function_code (ns=0x9634ea8)
    at ../../gcc-clean/gcc/fortran/trans-decl.c:2217
#5  0x08093f92 in gfc_generate_module_code (ns=0x9632550)
    at ../../gcc-clean/gcc/fortran/trans.c:708
#6  0x08079a50 in gfc_parse_file () at ../../gcc-clean/gcc/fortran/parse.c:2618
#7  0x08090735 in gfc_be_parse_file (set_yydebug=0)
    at ../../gcc-clean/gcc/fortran/f95-lang.c:265
#8  0x083ba13d in toplev_main (argc=0, argv=0xfef53ed4)
    at ../../gcc-clean/gcc/toplev.c:991
#9  0x00125ad4 in __libc_start_main () from /lib/tls/libc.so.6
#10 0x0804ab01 in _start ()
(gdb)

This looks like another bug. Will look it up in a minute.
Comment 2 Tobias Schlüter 2004-09-22 16:01:45 UTC
Couldn't find it. Maybe it's a new one after all.
Comment 3 Tobias Schlüter 2004-09-22 16:14:38 UTC
Couldn't find it. Maybe it's a new one after all. Confirmed for real, this time.
Comment 4 Tobias Schlüter 2004-09-24 17:55:38 UTC
Created attachment 7216 [details]
First attempt at fixing this PR

This is a patch which fixes the bug, but I haven't yet run the testsuite, and I
didn't look it through for stupid bugs. YMMV

ChangeLog:
2004-09-24  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

	PR fortran/17612
	* trans-expr.c (gfc_get_expr_strlen): New function.
	* trans.h (gfc_get_expr_strlen): Add prototype.
	* trans-array.c (gfc_conv_expr_descriptor): Use gfc_get_expr_strlen to
	determine string length.
Comment 5 Tobias Schlüter 2004-09-24 18:00:09 UTC
OK, I just looked at my testsuite run, and pr15324 is already broken again with
my patch. I'll look into this in more detail tomorrow.
Comment 6 Tobias Schlüter 2004-09-25 13:35:47 UTC
Created attachment 7217 [details]
Updated patch which fixes the bug

Updated patch which passes the testsuite. I still need to isolate a small
testcase before submitting it for review.
Comment 7 Tobias Schlüter 2004-09-25 14:25:30 UTC
Patch submitted for review: http://gcc.gnu.org/ml/fortran/2004-09/msg00252.html
Comment 8 Tobias Schlüter 2004-09-27 14:40:54 UTC
*** Bug 15494 has been marked as a duplicate of this bug. ***
Comment 9 Paul Brook 2004-10-04 13:12:18 UTC
Fixed.