Skip to content

Tests sometimes leak around 50 bytes #135628

Closed
@MRandl

Description

@MRandl

Code

Edit: the initial bug was found on nightly but it replicates on stable on a less up-to-date machine, see below

Similar to #135608 but not the same stack trace

$ cargo install cargo-valgrind 
$ cargo new valgrind-fails

add blank test in src/main.rs:

fn main() {
    println!("Hello, world!");
}

#[cfg(test)]
mod tests {
    #[test]
    pub fn hmm() {}
}


$ cargo +nightly valgrind test -r

Current output

Error leaked 48 B in 1 block
        Info stack trace (user code at the bottom)
             at malloc
             at std::thread::Thread::new
             at std::thread::current::init_current
             at std::sync::mpmc::context::Context::new
             at std::sys::thread_local::native::lazy::Storage<T,D>::initialize
             at std::sync::mpmc::list::Channel<T>::recv
             at test::console::run_tests_console
             at test::test_main
             at test::test_main_static
             at std::sys::backtrace::__rust_begin_short_backtrace
             at std::rt::lang_start::{{closure}}
             at std::rt::lang_start_internal
     Summary Leaked 48 B total (0 other errors)
error: test failed, to rerun pass `--bin valgrind-fails`

Desired output

Happy valgrind

Rationale and extra context

No response

Other cases

Rust Version

$ rustc --version --verbose
rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0
LLVM version: 19.1.5

Anything else?

I have

  • cargo 1.84.0 (66221abde 2024-11-19)
  • valgrind-3.18.1
  • Ubuntu 22.04.5 LTS (not checked on other OSes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions