Closed
Description
I tried this code:
use std::thread;
fn main() {
thread::spawn(|| println!("Hello, world!")).join().unwrap();
}
The code compiles and Hello, world! gets printed as expected but valgrind reports a leak of still reachable 32 Bytes:
==8853== Memcheck, a memory error detector
==8853== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==8853== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==8853== Command: ./target/release/thread_test
==8853==
Hello, world!
==8853==
==8853== HEAP SUMMARY:
==8853== in use at exit: 32 bytes in 1 blocks
==8853== total heap usage: 30 allocs, 29 frees, 4,048 bytes allocated
==8853==
==8853== 32 bytes in 1 blocks are still reachable in loss record 1 of 1
==8853== at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8853== by 0x4E3D7E4: _dlerror_run (dlerror.c:140)
==8853== by 0x4E3D165: dlsym (dlsym.c:70)
==8853== by 0x1178B2: fetch (weak.rs:61)
==8853== by 0x1178B2: get<unsafe extern "C" fn(*const libc::unix::linux_like::linux::gnu::b64::x86_64::pthread_attr_t) -> usize> (weak.rs:46)
==8853== by 0x1178B2: min_stack_size (thread.rs:439)
==8853== by 0x1178B2: std::sys::unix::thread::Thread::new (thread.rs:51)
==8853== by 0x10C8DD: std::thread::spawn (in /home/thread_test/target/release/thread_test)
==8853== by 0x10CE5F: thread_test::main (in /home/thread_test/target/release/thread_test)
==8853== by 0x10C682: std::rt::lang_start::{{closure}} (in /home/thread_test/target/release/thread_test)
==8853== by 0x116122: {{closure}} (rt.rs:52)
==8853== by 0x116122: std::panicking::try::do_call (panicking.rs:303)
==8853== by 0x118446: __rust_maybe_catch_panic (lib.rs:86)
==8853== by 0x116B2B: try<i32,closure-0> (panicking.rs:281)
==8853== by 0x116B2B: catch_unwind<closure-0,i32> (panic.rs:394)
==8853== by 0x116B2B: std::rt::lang_start_internal (rt.rs:51)
==8853== by 0x10CEE1: main (in /home/thread_test/target/release/thread_test)
==8853==
==8853== LEAK SUMMARY:
==8853== definitely lost: 0 bytes in 0 blocks
==8853== indirectly lost: 0 bytes in 0 blocks
==8853== possibly lost: 0 bytes in 0 blocks
==8853== still reachable: 32 bytes in 1 blocks
==8853== suppressed: 0 bytes in 0 blocks
==8853==
==8853== For counts of detected and suppressed errors, rerun with: -v
==8853== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Meta
rustc --version --verbose
:
rustc 1.43.0 (4fb7144ed 2020-04-20)
binary: rustc
commit-hash: 4fb7144ed159f94491249e86d5bbd033b5d60550
commit-date: 2020-04-20
host: x86_64-unknown-linux-gnu
release: 1.43.0
LLVM version: 9.0
Backtrace
Since the code runs, there is no backtrace :)