LLNL / sundials

Official development repository for SUNDIALS - a SUite of Nonlinear and DIfferential/ALgebraic equation Solvers. Pull requests are welcome for bug fixes and minor changes.
https://computing.llnl.gov/projects/sundials
BSD 3-Clause "New" or "Revised" License
520 stars 129 forks source link

[BUG] ARKodeSetDefaults Memory Leaks and Inconsistencies #554

Closed Steven-Roberts closed 1 week ago

Steven-Roberts commented 3 months ago

Current Behavior:

When ARKodeSetDefaults is called, some of the implementations NULL out Butcher tables and the nonlinear solver without freeing:

https://github.com/LLNL/sundials/blob/c28eaa3764a03705d61decb6025b409360e9d53f/src/arkode/arkode_arkstep_io.c#L680-L682

https://github.com/LLNL/sundials/blob/c28eaa3764a03705d61decb6025b409360e9d53f/src/arkode/arkode_erkstep_io.c#L310

https://github.com/LLNL/sundials/blob/c28eaa3764a03705d61decb6025b409360e9d53f/src/arkode/arkode_mristep_io.c#L255-L256

(SPRKStep appears ok)

Also ERKStep is the only implementation that resets the adaptivity controller.

Expected Behavior:

Objects should be freed and the workspace size should be updated appropriately. Also, ARKStep and ERKStep should be consistent about handling of adaptivity controller when ARKodeSetDefaults called.

Steps To Reproduce:

Call ARKodeSetDefaults after setting a Butcher table or nonlinear solver.

I've confirmed a memory leak with valgrind when ARKodeSetDefaults is called after ARKStepSetTableNum. Haven't tested further.

balos1 commented 1 week ago

Fixed by #560.