sundials icon indicating copy to clipboard operation
sundials copied to clipboard

Error Handler Memory Leak

Open Steven-Roberts opened this issue 1 year ago • 2 comments

If more than default error handler is added to a SUNContext, it does not get free'd in SUNContext_Free.

https://github.com/LLNL/sundials/blob/2abd63bd6cbc354fb4861bba8e98d0b95d65e24a/src/sundials/sundials_context.c#L288

https://github.com/LLNL/sundials/blob/2abd63bd6cbc354fb4861bba8e98d0b95d65e24a/src/sundials/sundials_errors.c#L42-L47

Either SUNContext_Free or SUNErrHandler_Destroy should traverse the list of error handlers through sunctx->err_handler->previous to free each.

Steven-Roberts avatar May 03 '24 00:05 Steven-Roberts

https://github.com/LLNL/sundials/blob/2abd63bd6cbc354fb4861bba8e98d0b95d65e24a/src/sundials/sundials_context.c#L288

This call to SUNErrHandler_Destory should be replaced with SUNContext_ClearErrHandlers

gardner48 avatar May 03 '24 00:05 gardner48

Ah great, there's already a function to do that. I swapped in SUNContext_ClearErrHandlers and valgrind reports no leaks. I'll turn it into a PR.

Steven-Roberts avatar May 03 '24 00:05 Steven-Roberts

Closed by #467

balos1 avatar May 05 '24 23:05 balos1