IBM Support

IZ84114: 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

    IZ84114

  • Reported component name

    XL FORTRAN FOR

  • Reported component ID

    5724X1500

  • Reported release

    D10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2010-08-31

  • Closed date

    2011-01-03

  • Last modified date

    2011-01-05

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

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

    LI75784

Fix information

  • Fixed component name

    XL FORTRAN FOR

  • Fixed component ID

    5724X1500

Applicable component levels

  • RD10 PSY U840772

       UP C

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH4D","label":"XL Fortran for AIX"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"13.1","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
05 January 2011