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

RootedRc::Drop and Root::Drop leak memory on panic #1

Open
sporksmith opened this issue May 14, 2022 · 1 comment
Open

RootedRc::Drop and Root::Drop leak memory on panic #1

sporksmith opened this issue May 14, 2022 · 1 comment

Comments

@sporksmith
Copy link
Owner

sporksmith commented May 14, 2022

This can be seen under miri in the should_panic tests.

It'd at least be good to add a way to free the data properly in tests, so that we can distinguish these leaks from other potential leaks. e.g. during unwind we could add pointers to things we'd otherwise leak to a global list that could be freed properly after catching the panic.

Maybe something like that could be exposed to crate users as well, though I don't see a way of implementing it that isn't super unsafe. Maybe the global could store something like Box<dyn Drop>, so that pointers can still be dropped properly, ignoring locking? We could expose an unsafe method like drop_leaked_objects to do it. (And maybe an alternative safe method that permanently leaks the objects instead)

In the meantime we can tell miri to ignore leaks. e.g.
MIRIFLAGS="-Zmiri-ignore-leaks" cargo miri test

@sporksmith
Copy link
Owner Author

Actually maybe the root could store the list, and drop all the items when it itself is dropped

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

No branches or pull requests

1 participant