Skip to content

Enable leak checker on Windows #1302

Closed
@RalfJung

Description

@RalfJung

Currently, the leak checker is disabled on Windows. This is because even a NOP program reports a leak:

The following memory was leaked:
alloc1821 (Rust heap, size: 40, align: 8) {
    0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
    0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
    0x20 │ __ __ __ __ __ __ __ __                         │ ░░░░░░░░
}
alloc1965 (Rust heap, size: 40, align: 8) {
    0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
    0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
    0x20 │ __ __ __ __ __ __ __ __                         │ ░░░░░░░░
}
alloc1997 (Rust heap, size: 24, align: 8) {
    0x00 │ ╾─────alloc1949+0─────╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........
    0x10 │ 01 00 00 00 __ __ __ __                         │ ....░░░░
}
alloc2395 (Rust heap, size: 40, align: 8) {
    0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
    0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
    0x20 │ __ __ __ __ __ __ __ __                         │ ░░░░░░░░
}
alloc2445 (Rust heap, size: 40, align: 8) {
    0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
    0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
    0x20 │ __ __ __ __ __ __ __ __                         │ ░░░░░░░░
}
alloc1949 (fn: std::sys_common::thread_local::register_dtor_fallback::run_dtors)

This leak is caused by static sys:common::mutex::Mutex, which store a pointer to some Rust heap allocation, cast to an integer (so even with #940 resolved, we do not "see" the pointer).

Even on a Windows host, you can avoid this problem by cross-running your program with --target x86_64-unknown-linux-gnu.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-leaksArea: affects the memory leak checkerA-windowsArea: affects only Windows targetsC-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