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

segfault with finalized dummy args

Ferdinand_T_
새로운 기여자 II
609 조회수

Hello!

The following program seems to reveal a compiler problem with finalized optional, allocatable polymorphic, intent(out) dummy arguments in a subprogram, which let the executable exit with a segfault on procedure entry(?).

[fortran]

module m

    implicit none

 

    ! finalized derived type

    type :: derived_type

    contains

        final :: finalizer

    end type

 

contains

    ! derived type's final subroutine

    subroutine finalizer(this)

        type(derived_type), intent(inout) :: this

    end subroutine

end module

 

program p

    use m

    implicit none

 

    call do_something()    ! runtime segfault

    ! forrtl: severe (174): SIGSEGV, segmentation fault occurred

contains

 

    ! a subprogram which returns finalized derived type

    ! important: intent(out), allocatable, optional

    subroutine do_something(arg)

        type(derived_type), intent(out), allocatable, optional :: arg

    end subroutine

end program

[/fortran]

Note: As far as I checked it, the arguments attributes must not be changed (allocatable to pointer etc.) for the program to exhibit the reported behaviour.

Best regards

Ferdinand

0 포인트
3 응답
Izaak_Beekman
새로운 기여자 II
609 조회수

Which version of ifort are you using? How did you compile this?

0 포인트
Ferdinand_T_
새로운 기여자 II
609 조회수

Recent ifort (unix) version 14.0.1, no compiler flags:

$ ifort test.f90
$ ./a.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
a.out              000000000046AEF9  Unknown               Unknown  Unknown
a.out              0000000000469870  Unknown               Unknown  Unknown
a.out              0000000000438E72  Unknown               Unknown  Unknown
a.out              000000000041F273  Unknown               Unknown  Unknown
a.out              00000000004041AB  Unknown               Unknown  Unknown
libpthread.so.0    00007F2C71C05CB0  Unknown               Unknown  Unknown
a.out              0000000000402CE4  Unknown               Unknown  Unknown
a.out              0000000000402C46  Unknown               Unknown  Unknown
libc.so.6          00007F2C7185776D  Unknown               Unknown  Unknown
a.out              0000000000402B19  Unknown               Unknown  Unknown

 

 

0 포인트
jimdempseyatthecove
명예로운 기여자 III
609 조회수

Assuming allocatable, optional and intent(out) ...without pointer...
are permitted together, the error (SIGSEGV) is doubly interesting since the final routine should only be called upon deallocate (implicit or explicit). The deallocate code should not have been generated.

Jim Dempsey

0 포인트
응답