Skip to content

Programs that cast function pointers have escalating memory use #3737

Closed
rust-lang/rust
#128742
@saethlin

Description

@saethlin

Since rust-lang/rust#123781, this program has unbounded memory use:

fn main() {
    loop {
        oof as fn(); // oof as usize also works
    }
}

fn oof() {}

Currently it looks like the memory use from this is about 1 GB/min, which means that in practice it's likely that this technically-unbounded memory use will go unnoticed.

But in general, I've been trying to make sure that Miri's memory usage is bounded on as many workloads as reasonable so that if we're too slow, users can fall back to just letting Miri run for a long time. If the interpreter's memory grows over that time without bound, that's not an option. So it would be nice if we didn't have this memory growth.

This reminds me a lot of the situation that prompted us to cache our evaluations of consts: rust-lang/rust#118336. Does a similar approach work here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-interpreterArea: affects the core interpreterC-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