Skip to content

Throwing a panic via core::panic reports memory leak #1071

@RalfJung

Description

@RalfJung

When a #[should_panic] test throws via core::panic! instead of (the default) std::panic!, we have a memory leak:

Alloc 23790: 00 00 00 00 00 00 00 00 0d 00 00 00 00 00 00 00 35 00 00 00 05 00 00 00 (24 bytes, alignment 8) (stack)
             └───────(23789)───────┘ 
Alloc 23789: 74 65 73 74 73 2f 74 65 73 74 2e 72 73 (13 bytes, alignment 1) (Static)

The 2nd allocation is the string tests/test.rs and 0x35 is 53, the line with the panic statement; this looks like some kind of panic information struct.

The interesting question is, why does a stack allocation not get freed?

Cc @Aaron1011

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-interpreterArea: affects the core interpreterA-panicsArea: affects panics and unwindingC-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