Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29275 Discussions

Ifort 11.1 can generate segmentation fault with => pointer assignment

Jean_Latour
Beginner
649 Views
Test case that aborts with segmentation fault when compiled with ifort 11.1 :

program main
!
Implicit none

Integer, parameter :: float_kind = SELECTED_REAL_KIND(12,307)
Integer, parameter :: ncomp = 3
Integer, parameter :: nd = 2

Type comp
Integer, Pointer :: vector (:)
Integer, Pointer :: ranks (:)
Real(float_kind), Pointer :: extents (:, :, :)
Integer, Pointer :: infos (:, :)
Integer :: glc
Integer :: cid
Integer :: siz
End Type comp

Type (comp), Allocatable :: all_comp_infos(:)
Type (comp), Allocatable, Target :: comp_infos(:)

Type (comp), Pointer :: b_comps (:)

Integer :: ierror
INteger :: i
!
! Define, allocate and initialize the target object
!
Allocate (comp_infos(ncomp), STAT = ierror)

do i = 1, ncomp
Allocate (comp_infos(i)%vector(1:nd), STAT = ierror)
Allocate (comp_infos(i)%ranks(1:nd), STAT = ierror)
Allocate (comp_infos(i)%extents(1:nd, 1:nd, 1:nd), STAT = ierror)
Allocate (comp_infos(i)%infos(nd, 1:nd), STAT = ierror)
comp_infos%glc = i+2
comp_infos%cid = i+3
comp_infos%siz = i+4
enddo
!
do i = 1, ncomp
comp_infos(i)%vector(:) = 33
comp_infos(i)%ranks(:) = 44
comp_infos(i)%extents(:,:,:) = 55
comp_infos(i)%infos(:,:) = 66
enddo
!
! Associate a pointer on the target
!
print *,' before associating b_comps pointer'
b_comps => comp_infos
!
print *,' siz in comp_infos = ',comp_infos(1)%siz
print *,' siz in b_comps = ',b_comps(1)%siz
print *,' b_comps : cid = ',b_comps(1)%cid
print *,' b_comps : glc = ',b_comps(1)%glc
!
! Defines and allocate a new object
!
Allocate (all_comp_infos(1:ncomp), STAT = ierror)
!
! Initialize new object with pointer components
!
! 1) Scalar components
do i = 1, ncomp
all_comp_infos(i)%siz = b_comps(i)%siz
all_comp_infos(i)%cid = b_comps(i)%cid
all_comp_infos(i)%glc = b_comps(i)%glc
enddo
do i = 1, ncomp
print *,'siz in all_comp_infos(:) = ',all_comp_infos(i)%siz
print *,'cid in all_comp_infos(:) = ',all_comp_infos(i)%cid
print *,'glc in all_comp_infos(:) = ',all_comp_infos(i)%glc
enddo
!
! 2) pointers components
do i = 1, ncomp
all_comp_infos(i)%vector => b_comps(i)%vector
print *,'b_comps Vector = ',b_comps(i)%vector
print *,'all_comp_infos Vector = ',all_comp_infos(i)%vector

all_comp_infos(i)%ranks => b_comps(i)%ranks
print *,'b_comps Vector = ',b_comps(i)%ranks
print *,'all_comp_infos Vector = ',all_comp_infos(i)%ranks

all_comp_infos(i)%extents => b_comps(i)%extents
print *,'b_comps Vector = ',b_comps(i)%extents
print *,'all_comp_infos Vector = ',all_comp_infos(i)%extents

all_comp_infos(i)%infos => b_comps(i)%infos
print *,'b_comps Vector = ',b_comps(i)%infos
print *,'all_comp_infos Vector = ',all_comp_infos(i)%infos
enddo
!
do i = 1, ncomp
Deallocate (all_comp_infos(i)%vector)
Deallocate (all_comp_infos(i)%ranks)
Deallocate (all_comp_infos(i)%extents)
Deallocate (all_comp_infos(i)%infos)
end do

Deallocate (comp_infos)

!===> All done

stop
end program main
0 Kudos
5 Replies
Ron_Green
Moderator
649 Views
works fine for me even without unlimiting the stacksize:

http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/

rwgreen@spdr65:~> ifort -o ptralloc ptralloc.f90 -xhost -g -O2 -traceback
rwgreen@spdr65:~> ./ptralloc
before associating b_comps pointer
siz in comp_infos = 7
siz in b_comps = 7
b_comps : cid = 6
b_comps : glc = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66


are you on Linux or Mac? What version of 11.1? ifort -V to determine version.

ron
0 Kudos
Jean_Latour
Beginner
649 Views
works fine for me even without unlimiting the stacksize:

http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/

rwgreen@spdr65:~> ifort -o ptralloc ptralloc.f90 -xhost -g -O2 -traceback
rwgreen@spdr65:~> ./ptralloc
before associating b_comps pointer
siz in comp_infos = 7
siz in b_comps = 7
b_comps : cid = 6
b_comps : glc = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66

are you on Linux or Mac? What version of 11.1? ifort -V to determine version.

ron

Jean : On two systems tested : (SUN AMD248, and IBM cluster with Intel Nehalem), ifort version is :

Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090511 Package ID: l_cprof_p_11.1.038
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

For AMD server the Linux system is :
Linux version is : 2.6.18-92.1.6.el5 #1 SMP Wed Jun 25 12:38:37 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux


output of test is :

before associating b_comps pointer
siz in comp_infos = 7
siz in b_comps = 7
b_comps : cid = 6
b_comps : glc = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector =
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector =
b_comps Vector = 66 66 66 66
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
imain 00000000004047F7 Unknown Unknown Unknown
imain 0000000000402ACC Unknown Unknown Unknown
libc.so.6 00000034BE01D8B4 Unknown Unknown Unknown
imain 00000000004029D9 Unknown Unknown Unknown

It fails always when using the SECOND pointer : (ranks), in the "comp" derived type.
The values are lost.
Same thing for the 3rd (extents) and the fourth (infos) pointers.
Only the assignment and use of the FIRST pointer (vector) is OK.

This construct is used in a large application, and it is OK with all other compilers
I have tested, including older versions of ifort.

If your version of ifort 11.1 works OK, I'll be happy to use it.

The abort message is different in a more complex case where several layers of
subroutines are involved : the message is then something like :
"attempt to use a pointer that has not been assigned"
This occurs when printing the second field (ranks).

Thanks for your help and support,
Best Regards,
Jean


0 Kudos
Jean_Latour
Beginner
649 Views
Quoting - Jean Latour
works fine for me even without unlimiting the stacksize:

http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/

rwgreen@spdr65:~> ifort -o ptralloc ptralloc.f90 -xhost -g -O2 -traceback
rwgreen@spdr65:~> ./ptralloc
before associating b_comps pointer
siz in comp_infos = 7
siz in b_comps = 7
b_comps : cid = 6
b_comps : glc = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector = 44 44
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
b_comps Vector = 66 66 66 66
all_comp_infos Vector = 66 66 66 66

are you on Linux or Mac? What version of 11.1? ifort -V to determine version.

ron

Jean : On two systems tested : (SUN AMD248, and IBM cluster with Intel Nehalem), ifort version is :

Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090511 Package ID: l_cprof_p_11.1.038
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

For AMD server the Linux system is :
Linux version is : 2.6.18-92.1.6.el5 #1 SMP Wed Jun 25 12:38:37 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux


output of test is :

before associating b_comps pointer
siz in comp_infos = 7
siz in b_comps = 7
b_comps : cid = 6
b_comps : glc = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
siz in all_comp_infos(:) = 7
cid in all_comp_infos(:) = 6
glc in all_comp_infos(:) = 5
b_comps Vector = 33 33
all_comp_infos Vector = 33 33
b_comps Vector = 44 44
all_comp_infos Vector =
b_comps Vector = 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
55.0000000000000 55.0000000000000 55.0000000000000
all_comp_infos Vector =
b_comps Vector = 66 66 66 66
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
imain 00000000004047F7 Unknown Unknown Unknown
imain 0000000000402ACC Unknown Unknown Unknown
libc.so.6 00000034BE01D8B4 Unknown Unknown Unknown
imain 00000000004029D9 Unknown Unknown Unknown

It fails always when using the SECOND pointer : (ranks), in the "comp" derived type.
The values are lost.
Same thing for the 3rd (extents) and the fourth (infos) pointers.
Only the assignment and use of the FIRST pointer (vector) is OK.

This construct is used in a large application, and it is OK with all other compilers
I have tested, including older versions of ifort.

If your version of ifort 11.1 works OK, I'll be happy to use it.

The abort message is different in a more complex case where several layers of
subroutines are involved : the message is then something like :
"attempt to use a pointer that has not been assigned"
This occurs when printing the second field (ranks).

Thanks for your help and support,
Best Regards,
Jean





Hello Ron,

I'd like to know which version of ifort you are using in your (successfull) test.
My (failing) version is :
Version 11.1 Build 20090511 Package ID: l_cprof_p_11.1.038

Thanks a lot,
Jean


0 Kudos
Kevin_D_Intel
Employee
649 Views

The SegV is reproducible using 11.1.038 (see below).

$ ifort -V
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090511 Package ID: l_cprof_p_11.1.038

It is not reproducible using 11.1.046 (see below).

$ ifort -V
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090630 Package ID: l_cprof_p_11.1.046

I suspect Ron used the latter.

A new 11.1 update is due out any day now also that should also contain the fix if you wish, however, 11.1.046 fixes this particular issue.
0 Kudos
Jean_Latour
Beginner
649 Views
Quoting - Jean Latour
Test case that aborts with segmentation fault when compiled with ifort 11.1 :

program main
!
Implicit none

Integer, parameter :: float_kind = SELECTED_REAL_KIND(12,307)
Integer, parameter :: ncomp = 3
Integer, parameter :: nd = 2

Type comp
Integer, Pointer :: vector (:)
Integer, Pointer :: ranks (:)
Real(float_kind), Pointer :: extents (:, :, :)
Integer, Pointer :: infos (:, :)
Integer :: glc
Integer :: cid
Integer :: siz
End Type comp

Type (comp), Allocatable :: all_comp_infos(:)
Type (comp), Allocatable, Target :: comp_infos(:)

Type (comp), Pointer :: b_comps (:)

Integer :: ierror
INteger :: i
!
! Define, allocate and initialize the target object
!
Allocate (comp_infos(ncomp), STAT = ierror)

do i = 1, ncomp
Allocate (comp_infos(i)%vector(1:nd), STAT = ierror)
Allocate (comp_infos(i)%ranks(1:nd), STAT = ierror)
Allocate (comp_infos(i)%extents(1:nd, 1:nd, 1:nd), STAT = ierror)
Allocate (comp_infos(i)%infos(nd, 1:nd), STAT = ierror)
comp_infos%glc = i+2
comp_infos%cid = i+3
comp_infos%siz = i+4
enddo
!
do i = 1, ncomp
comp_infos(i)%vector(:) = 33
comp_infos(i)%ranks(:) = 44
comp_infos(i)%extents(:,:,:) = 55
comp_infos(i)%infos(:,:) = 66
enddo
!
! Associate a pointer on the target
!
print *,' before associating b_comps pointer'
b_comps => comp_infos
!
print *,' siz in comp_infos = ',comp_infos(1)%siz
print *,' siz in b_comps = ',b_comps(1)%siz
print *,' b_comps : cid = ',b_comps(1)%cid
print *,' b_comps : glc = ',b_comps(1)%glc
!
! Defines and allocate a new object
!
Allocate (all_comp_infos(1:ncomp), STAT = ierror)
!
! Initialize new object with pointer components
!
! 1) Scalar components
do i = 1, ncomp
all_comp_infos(i)%siz = b_comps(i)%siz
all_comp_infos(i)%cid = b_comps(i)%cid
all_comp_infos(i)%glc = b_comps(i)%glc
enddo
do i = 1, ncomp
print *,'siz in all_comp_infos(:) = ',all_comp_infos(i)%siz
print *,'cid in all_comp_infos(:) = ',all_comp_infos(i)%cid
print *,'glc in all_comp_infos(:) = ',all_comp_infos(i)%glc
enddo
!
! 2) pointers components
do i = 1, ncomp
all_comp_infos(i)%vector => b_comps(i)%vector
print *,'b_comps Vector = ',b_comps(i)%vector
print *,'all_comp_infos Vector = ',all_comp_infos(i)%vector

all_comp_infos(i)%ranks => b_comps(i)%ranks
print *,'b_comps Vector = ',b_comps(i)%ranks
print *,'all_comp_infos Vector = ',all_comp_infos(i)%ranks

all_comp_infos(i)%extents => b_comps(i)%extents
print *,'b_comps Vector = ',b_comps(i)%extents
print *,'all_comp_infos Vector = ',all_comp_infos(i)%extents

all_comp_infos(i)%infos => b_comps(i)%infos
print *,'b_comps Vector = ',b_comps(i)%infos
print *,'all_comp_infos Vector = ',all_comp_infos(i)%infos
enddo
!
do i = 1, ncomp
Deallocate (all_comp_infos(i)%vector)
Deallocate (all_comp_infos(i)%ranks)
Deallocate (all_comp_infos(i)%extents)
Deallocate (all_comp_infos(i)%infos)
end do

Deallocate (comp_infos)

!===> All done

stop
end program main

----------------------------------------------------------------------------------------

Thanks a lot to Rnald Green and Ken Davis for their answers.
We should update soon the ifort compiler to the lastest version
(11.1.048 or later).

Best Regards,
Jean Latour

0 Kudos
Reply