For various reasons, a number of types in elfmalloc cannot free all of their resources in Drop::drop, and instead require that a custom cleanup method is called before drop. Usually this is because the object itself does not contain the allocators to which resources should be freed, and they need to be passed as parameters.
This works most of the time, but will fail if certain routines bail in the middle. Notable examples are Clone::clone and various constructors. If allocation fails in these routines and they return early or panic, the custom cleanup methods for any objects in the local scope will not be called, and we will leak resources.
This should be fixed. I have annotated all such issues that I can find with a comment and a reference to this issue. Ideally, a solution would be a general one (e.g., some special type that has temporary access to the requisite allocators for the duration of the function scope so that it can call the custom cleanup methods if the function bails early).
For various reasons, a number of types in
elfmalloc
cannot free all of their resources inDrop::drop
, and instead require that a custom cleanup method is called before drop. Usually this is because the object itself does not contain the allocators to which resources should be freed, and they need to be passed as parameters.This works most of the time, but will fail if certain routines bail in the middle. Notable examples are
Clone::clone
and various constructors. If allocation fails in these routines and they return early or panic, the custom cleanup methods for any objects in the local scope will not be called, and we will leak resources.This should be fixed. I have annotated all such issues that I can find with a comment and a reference to this issue. Ideally, a solution would be a general one (e.g., some special type that has temporary access to the requisite allocators for the duration of the function scope so that it can call the custom cleanup methods if the function bails early).