sporksmith/objgraph

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

Opened this issue · 1 comments

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

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