Finalize() problem in my own code's adapter

Hi preCICE developer and user~

I just finished my FEM code’s adapter, but problem happended in the final step, which is finalizing the preCICE.

My code is written by fortran language, so in finalize subroutine, as show:

subroutine finalize()
  implicit none
  INTEGER :: isOngoing

  call precicef_is_coupling_ongoing(isOngoing)

  if ( preciceInitialized_ .and. isOngoing == 0 ) then
    call precicef_finalize()
    preciceInitialized_ = .false.
    ! Delete the solver interface and all the related data
    call teardown()
  else
    write(msg,'(a)') '* Could not finalize preCICE. Error!!!'
    call printf( msg = msg );    mfid = Message_ID;    call printf(mfid, msg)
  end if

end subroutine finalize

And I test my adapter with solverdummy. I found out that after calling call precicef_finalize(), error shows:

* The coupling completed.
* Finalizing the preCICE solver interface...
(0) 15:19:22 [impl::ParticipantImpl]:1555 in closeCommunicationChannels: Close communication channels
malloc(): largebin double linked list corrupted (bk)
forrtl: error (76): Abort trap signal
Image              PC                Routine            Line        Source             
libpthread-2.31.s  00007F0D9A14F420  Unknown               Unknown  Unknown
libc-2.31.so       00007F0D99F8A00B  gsignal               Unknown  Unknown
libc-2.31.so       00007F0D99F69859  abort                 Unknown  Unknown
libc-2.31.so       00007F0D99FD426E  Unknown               Unknown  Unknown
libc-2.31.so       00007F0D99FDC2FC  Unknown               Unknown  Unknown
libc-2.31.so       00007F0D99FDC94C  Unknown               Unknown  Unknown
libc-2.31.so       00007F0D99FDDE8B  Unknown               Unknown  Unknown
libc-2.31.so       00007F0D99FE188D  Unknown               Unknown  Unknown
libpthread-2.31.s  00007F0D9A14362F  Unknown               Unknown  Unknown
libc-2.31.so       00007F0D9A066353  clone                 Unknown  Unknown

The info seems relevant to double-linked list in preCICE, so I don’t know how to solve it, has anyone encounter similar problem?

Thank you !!!

I think I may have solved the problem, maybe related to the data buffer.