Seek debugging tip for crash at nullify call

Tobias Burnus burnus@net-b.de
Thu Oct 5 20:27:00 GMT 2006


Hello,

does someone has an idea how to debug the following program?

(This is with 4.2.0 20061005, I don't have the TR patch applied.)

I get a segmentation fault when I'm nullifying a variable; essential
part is:

nullify(ep%p)
print *,'associated(ep%p) =', associated(ep%p) ! => associated(ep%p) = F
allocate(ep%p(ep%nvnl),stat=i) ! => stat = 0; ep%nvnl = 9
print *,'associated(ep%p) =', associated(ep%p) ! => associated(ep%p) = T
nullify(ep%p(1)%jxyz) ! => SIGSEGV


303         nullify(ep%p)
305         nullify(ep%dp)
306         nullify(ep%lso)
307         print *,'associated(ep%p) =', associated(ep%p)
 associated(ep%p) = F
308         if(ep%nvnl > 0) then
309           flush(6)
310           i = 42
312      if(global_alloc_err.ne.0) then
315           allocate(ep%p(ep%nvnl),stat=i)
316         print *,'associated(ep%p) =', associated(ep%p)
 associated(ep%p) = T
317           print *, 'ep%nvnl:', ep%nvnl, ' stat = ',i
 ep%nvnl:           9  stat =            0
318           print *,'DEBUG 1'
 DEBUG 1
319           flush(6)
320           do i = 1, ep%nvnl
321             print *,'DEBUG 1.',i
 DEBUG 1.           1
322             flush(6)
323         print *,'associated(ep%p(i)%jxyz) =', associated(ep%p(i)%jxyz)
 associated(ep%p(i)%jxyz) = T
324             flush(6)
(gdb) next
325             nullify(ep%p(i)%jxyz)
(gdb) step

Program received signal SIGSEGV, Segmentation fault.
0x00000000006cb99a in __external_pot_m__epot_init (ep=@0xefcf48,
gr=@0xf36460, geo=@0xefd260) at epot.F90:325
325             nullify(ep%p(i)%jxyz)



Ok, the most important data elements are:

  type projector_t
    integer :: n_points_in_sphere
    integer :: n_channels
    integer, pointer :: jxyz(:)
    real(8), pointer :: uvu(:, :)
    real(8), pointer :: ket(:, :), bra(:, :)
    complex(8), pointer :: phases(:, :)
    integer :: iatom
  end type projector_t

  type epot_t
    integer :: nvnl ! number of nonlocal operators
    type(projector_t), pointer :: p(:)
    [...]
end type epot_t

  subroutine epot_init(ep, gr, geo)
    type(epot_t), intent(out) :: ep
[...]
    ep%nvnl = geometry_nvnl(geo)
    nullify(ep%p)
[...]
    print *,'associated(ep%p) =', associated(ep%p)
    if(ep%nvnl > 0) then
      flush(6)
      i = 42
      allocate(ep%p(ep%nvnl),stat=i)
    print *,'associated(ep%p) =', associated(ep%p)
      print *, 'ep%nvnl:', ep%nvnl, ' stat = ',i
      print *,'DEBUG 1'
      flush(6)
      do i = 1, ep%nvnl
        print *,'DEBUG 1.',i
        flush(6)
    print *,'associated(ep%p(i)%jxyz) =', associated(ep%p(i)%jxyz)
        flush(6)
        nullify(ep%p(i)%jxyz)
[...]


Thanks for any tips,

Tobias



More information about the Fortran mailing list