Skip to content

bug: tau_Re_vf memory leak in Cartesian viscous runs (dealloc only under cyl_coord) #1366

@sbryngelson

Description

@sbryngelson

Summary

In src/simulation/m_rhs.fpp, tau_Re_vf is allocated inside if (viscous) but deallocated only when cyl_coord is also true:

! Allocation (inside if (viscous)):
@:ALLOCATE(tau_Re_vf(1:sys_size))
do i = 1, Re_size(1)
    @:ALLOCATE(tau_Re_vf(eqn_idx%cont%end + i)%sf(...))
end do
@:ALLOCATE(tau_Re_vf(eqn_idx%E)%sf(...))

! Deallocation (inside if (cyl_coord)):
if (cyl_coord) then
    do i = 1, num_dims
        @:DEALLOCATE(tau_re_vf(eqn_idx%cont%end + i)%sf)
    end do
    @:DEALLOCATE(tau_re_vf(eqn_idx%E)%sf)
    @:DEALLOCATE(tau_re_vf)
end if

Any run with viscous = .true. and cyl_coord = .false. (i.e., every Cartesian viscous simulation) leaks all tau_Re_vf GPU and host allocations. Violates the @:ALLOCATE/@:DEALLOCATE pairing rule.

Fix

The deallocation guard should be if (viscous), not if (cyl_coord). The number of sf sub-arrays to free mirrors the allocation loop (one per viscous fluid, plus the energy slot).

Discovered

Found during review of PR #1365. Pre-existing in master.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working or doesn't seem right

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions