IBM Support

LI75784: FORTRAN POINTER DEALLOCATION ERROR

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • A deallocation error is encountered during the following
    situation:
    
    From a Fortran routine, data is allocated. c_loc is used to get
    a C-pointer to point to that data, which is passed to the
    C-layer. That C-pointer is passed back to a second Fortran
    routine. The deallocation of this second Fortran pointer is what
    causes this error to occur.
    
         write(0,*) "zz=",zz
         cptr = c_loc(zz)
    !
    !   pass cptr to C-layer
    !
    ! ----------8<----------8<----------
    !
    ! subroutine fortran2(cptr)
    !
         call c_f_pointer(cptr, xy)
       ! xy => zz
         write(0,*) "xy=",xy
    
    So zz is a local Fortran pointer in the first routine, and xy is
    another local Fortran pointer in the second routine.
    
    
    ===== Test Case:
    
      program c_ptr_test
      use iso_c_binding
      implicit none
      type(c_ptr) :: cptr
      real*8, pointer :: zz, xy
        write(0,*) 'Allocate zz'
        allocate(zz)
        zz=5.d0
        write(0,*) "zz=",zz
        cptr = c_loc(zz)
        call c_f_pointer(cptr, xy)
      ! xy => zz
        write(0,*) "xy=",xy
        write(0,*) "Deallocate xy"
        deallocate(xy)
      end program c_ptr_test
    
    ==============================
    
    
    When this test case is compiled using XL Fortran V13.1 on AIX,
    the following message is observed.
    
    
    $ xlf90 c_ptr_test.f90
    $ ./a.out
     Allocate zz
     zz= 5.00000000000000000
     xy= 5.00000000000000000
     Deallocate xy
    "c_ptr_test.f90", line 15: 1525-109 Error encountered while
    attempting to deallocate a data object.  The program will stop.
    $
    

Local fix

  • N/A.
    

Problem summary

  • PROBLEM DESCRIPTION:
    Information about the permissibility of passing a pointer to
    deallocate is lost after passing the pointer through C_PTR.
    
    USERS AFFECTED:
    Fortran users passing c_ptr pointers through bind(c) and back
    into a fortran pointer.
    

Problem conclusion

  • Several workarounds were identified for this situation, but it
    is best to address this issue in your source. if this is not an
    option, please contact IBM support for a workaround that
    switches the default behaviour of c_ptr.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI75784

  • Reported component name

    XL FORTRAN LINU

  • Reported component ID

    5724X1600

  • Reported release

    D10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2010-11-23

  • Closed date

    2010-11-23

  • Last modified date

    2010-11-23

  • APAR is sysrouted FROM one or more of the following:

    IZ84114

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    XL FORTRAN LINU

  • Fixed component ID

    5724X1600

Applicable component levels

  • RD10 PSY

       UP

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSAT4T","label":"XL Fortran for Linux"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"D10","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
15 October 2021