Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sleep causes memory leak according to valgrind #21371

Closed
petermora opened this issue Jan 18, 2015 · 1 comment
Closed

Sleep causes memory leak according to valgrind #21371

petermora opened this issue Jan 18, 2015 · 1 comment

Comments

@petermora
Copy link

I guess that valgrind should always return 0 used bytes at exit. The code only sleeps for 5 seconds:

#[allow(unstable)]
fn main() {
  std::io::timer::sleep(std::time::duration::Duration::seconds(5));
}

I'm on 64 bit Debian testing. Version of Rust:

rustc --version --verbose
rustc 1.0.0-nightly (ed530d7a3 2015-01-16 22:41:16 +0000)
binary: rustc
commit-hash: ed530d7a3b67989047e6fe61fe101b9d8158585f
commit-date: 2015-01-16 22:41:16 +0000
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly

Valgrind output:

valgrind --leak-check=full ../target/hello                                                                          [11/198]
==3789== Memcheck, a memory error detector
==3789== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==3789== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==3789== Command: ../target/hello
==3789== 
==3789== 
==3789== HEAP SUMMARY:
==3789==     in use at exit: 904 bytes in 13 blocks
==3789==   total heap usage: 33 allocs, 20 frees, 2,400 bytes allocated
==3789== 
==3789== 288 bytes in 1 blocks are possibly lost in loss record 13 of 13
==3789==    at 0x4C2AD10: calloc (vg_replace_malloc.c:623)
==3789==    by 0x4010FD1: allocate_dtv (dl-tls.c:296)
==3789==    by 0x40116DD: _dl_allocate_tls (dl-tls.c:460)
==3789==    by 0x5041C27: allocate_stack (allocatestack.c:589)
==3789==    by 0x5041C27: pthread_create@@GLIBC_2.2.5 (pthread_create.c:495)
==3789==    by 0x1148F4: sys::thread::create::hcba76e95a3a3ee63jTw (in /home/petya/rust/hello/target/hello)
==3789==    by 0x112669: thread::Builder::spawn_inner::h5695881126130537417 (in /home/petya/rust/hello/target/hello)
==3789==    by 0x118BAA: io::timer::Timer::new::h6de63c2656b477e2e0g (in /home/petya/rust/hello/target/hello)
==3789==    by 0x11805A: io::timer::sleep::he75e770508550e27QZg (in /home/petya/rust/hello/target/hello)
==3789==    by 0x10EC95: main::h655d5e7b0d3f884beaa (main.rs:4)
==3789==    by 0x132AF8: rust_try_inner (in /home/petya/rust/hello/target/hello)
==3789==    by 0x132AE5: rust_try (in /home/petya/rust/hello/target/hello)
==3789==    by 0x1301B5: rt::lang_start::h8024648b47185c9dZ0z (in /home/petya/rust/hello/target/hello)
==3789== 
==3789== LEAK SUMMARY:
==3789==    definitely lost: 0 bytes in 0 blocks
==3789==    indirectly lost: 0 bytes in 0 blocks
==3789==      possibly lost: 288 bytes in 1 blocks
==3789==    still reachable: 616 bytes in 12 blocks
==3789==         suppressed: 0 bytes in 0 blocks
==3789== Reachable blocks (those to which a pointer was found) are not shown.
==3789== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3789== 
==3789== For counts of detected and suppressed errors, rerun with: -v
==3789== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
@alexcrichton
Copy link
Member

Closing as a dupe of #20012 (this is a result of not running at_exit callbacks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants