Skip to content

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

@sporksmith

Description

@sporksmith

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions