Skip to content

Leaking a heap allocation of pointer results in confusing output #2812

@nonl4331

Description

@nonl4331

Take the code:

let local = 0usize;
let leak_this = Box::new(&local as *const usize);
Box::into_raw(leak_this);

Running cargo miri run produces the following output:

The following memory was leaked: alloc1673 (Rust heap, size: 8, align: 8) {
    ╾0x28970[a1657]<3157>─╼                         │ ╾──────╼
}
alloc1657 (deallocated)

It is not immediately clear why alloc1657 is shown or the relation between alloc1673 and alloc1657. If alloc1657 were not deallocated it would be possible to interpret alloc1657 as leaked memory.
One suggestion would be to explicitly mention that the leaked memory contains alloc1657 and expand a1657 to alloc1657 for clarity.

The following memory was leaked: alloc1673 (Rust heap, size: 8, align: 8) {
    ╾0x28970[alloc1657]<3157>─╼                         │ ╾──────╼
}
alloc1673 contains a pointer: alloc1657 (deallocated)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions