Skip to content

Memory leak checker misses pointers stored as integers #1618

Open
@RalfJung

Description

@RalfJung

Our memory leak checker works by figuring out which memory is reachable from global statics (or any pointer passed to miri_static_root) when the program finishes, and considering all unreachable memory "leaked". Reachability is determined by looking for proper pointers, i.e., pointer provenance needs to be intact so that we can distinguish them from integers.

But this means when some piece of memory is only reachable through a pointer that is only stored as an integer without provenance, we will miss that pointer and consider the memory leaked.

I have no good idea for how to improve the situation -- I don't think we want to cast all integers to pointers in the hope that they are an actual allocation; that would be extremely expensive and also rather hacky. miri_static_root can sometimes be used to work around this, but it is not a great solution either. Absent any ideas how to improve this, I am inclined to just say "works as intended", but people are going to run into this problem so it seems worth tracking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-leaksArea: affects the memory leak checkerC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions