Skip to content

Commit

Permalink
SeaState: [BugFix] add check on nullify commands
Browse files Browse the repository at this point in the history
openfast(66108,0x10fb1edc0) malloc: *** error for object 0x7fe4a223a000: pointer being freed was not allocated
openfast(66108,0x10fb1edc0) malloc: *** set a breakpoint in malloc_error_break to debug

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
\#0  0x103a3f33d
\#1  0x103a3e76d
\#2  0x7fff68c225fc
Abort trap: 6
  • Loading branch information
andrew-platt committed Mar 9, 2022
1 parent 4de7ac4 commit a5aea78
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,18 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
CALL HydroDyn_Init( Init%InData_HD, HD%Input(1), HD%p, HD%x(STATE_CURR), HD%xd(STATE_CURR), HD%z(STATE_CURR), &
HD%OtherSt(STATE_CURR), HD%y, HD%m, p_FAST%dt_module( MODULE_HD ), Init%OutData_HD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)

! 1) Nullify the HD Init Input pointers (do this now in case HD_Init failed)
! 2) Now, when HydroDyn_DestroyInitInput is called and hence SeaState_DestroyInitOutput, we will not deallocate data which is still in use because the is associated test will fail.
nullify(Init%InData_HD%WaveElevC0)
nullify(Init%InData_HD%WaveDirArr)
nullify(Init%InData_HD%WaveDynP)
nullify(Init%InData_HD%WaveAcc)
nullify(Init%InData_HD%WaveVel)
nullify(Init%InData_HD%WaveTime)
nullify(Init%InData_HD%WaveElev1)
nullify(Init%InData_HD%WaveElev2)

! If HD_Init failed, cleanup and exit
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
Expand Down Expand Up @@ -862,19 +873,6 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
if (allocated(Init%OutData_HD%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_HD)%Instance(1)%NumOutputs = size(Init%OutData_HD%WriteOutputHdr)
end if

! 1) Nullify the HD Init Input pointers
! 2) Now, when HydroDyn_DestroyInitInput is called and hence SeaState_DestroyInitOutput, we will not deallocate data which is still in use because the is associated test will fail.

nullify(Init%InData_HD%WaveElevC0)
nullify(Init%InData_HD%WaveDirArr)
nullify(Init%InData_HD%WaveDynP)
nullify(Init%InData_HD%WaveAcc)
nullify(Init%InData_HD%WaveVel)
nullify(Init%InData_HD%WaveTime)
nullify(Init%InData_HD%WaveElev1)
nullify(Init%InData_HD%WaveElev2)


IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
Expand Down

0 comments on commit a5aea78

Please sign in to comment.