Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elfmalloc: Don't leak resources when allocation fails #179

Open
joshlf opened this issue Mar 20, 2018 · 0 comments
Open

elfmalloc: Don't leak resources when allocation fails #179

joshlf opened this issue Mar 20, 2018 · 0 comments

Comments

@joshlf
Copy link
Collaborator

joshlf commented Mar 20, 2018

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant