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

ifx: a segmentation fault with -heap-arrays

riad_h_1
Novice
512 Views

Dear all,

I get a segfault when I compile my code with the option -heap-arrays n (whatever the value of n, even 0).  

Here's an example that reproduces this error.

 

type :: my_t
   integer, allocatable :: m(:) 
end type my_t

type(my_t), allocatable :: s(:)

s = myalloc_fun ( 10 ) !< KO: segmentation fault 

! But OK with a subroutine version of myalloc_fun:
!call myalloc_sub ( 10, s )

! And also OK with a direct call to allocate:
!allocate(s(10)) !< and OK 

contains

   function myalloc_fun ( n ) result( x )
      integer, intent(in) :: n
      type(my_t), allocatable :: x(:)

      allocate(x(n))
   end function myalloc_fun


   subroutine myalloc_sub ( n, x )
      integer, intent(in) :: n
      type(my_t), allocatable, intent(out) :: x(:)

      allocate(x(n))
   end subroutine myalloc_sub

end

 

Compiler version: ifx (IFX) 2024.1.2 20240508

(Sorry, I cannot try with the latest version at the moment; I am not the administrator of the computer. But please let me know if this bug also occurs with a more recent version).

 

ifx alloc.f90 -heap-arrays 0 -traceback
./a.out

forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
libpthread-2.31.s  00007FC31804E910  Unknown               Unknown  Unknown
a.out              000000000040A1C1  Unknown               Unknown  Unknown
a.out              00000000004093B6  Unknown               Unknown  Unknown
a.out              000000000040A1EE  Unknown               Unknown  Unknown
a.out              00000000004093B6  Unknown               Unknown  Unknown
a.out              0000000000404841  _unnamed_main$$             7  alloc.f90
a.out              000000000040422D  Unknown               Unknown  Unknown
libc-2.31.so       00007FC317E6F24D  __libc_start_main     Unknown  Unknown
a.out              000000000040415A  Unknown               Unknown  Unknown

 

Thanks

0 Kudos
1 Solution
TobiasK
Moderator
417 Views

@riad_h_1


thanks for reporting this. The segmentation fault is already fixed in our internal development version, and the fix will be included in the 2025.0 release.


View solution in original post

1 Reply
TobiasK
Moderator
418 Views

@riad_h_1


thanks for reporting this. The segmentation fault is already fixed in our internal development version, and the fix will be included in the 2025.0 release.


Reply