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

valgrind shows memory leak for a simple print statement #19776

Open
rjammala opened this Issue Dec 12, 2014 · 22 comments

Comments

Projects
None yet
@rjammala

rjammala commented Dec 12, 2014

Here are the details:
$ valgrind --version
valgrind-3.8.1

rustc --version
rustc 0.13.0-nightly (193390d 2014-12-11 22:56:54 +0000)

uname -a
Linux 2.6.32-504.1.3.el6.x86_64 #1 SMP Tue Nov 11 17:57:25 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Here is the program:

$ cat learn.rs
fn main() {
println!("Hello World!")
println!("How are you today")
}

$ valgrind --leak-check=full ./learn
==38235== Memcheck, a memory error detector
==38235== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==38235== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==38235== Command: ./learn
==38235==

Hello World!
How are you today
==38235==
==38235== HEAP SUMMARY:
==38235== in use at exit: 1,184 bytes in 4 blocks
==38235== total heap usage: 18 allocs, 14 frees, 2,696 bytes allocated
==38235==
==38235== LEAK SUMMARY:
==38235== definitely lost: 0 bytes in 0 blocks
==38235== indirectly lost: 0 bytes in 0 blocks
==38235== possibly lost: 0 bytes in 0 blocks
==38235== still reachable: 1,184 bytes in 4 blocks
==38235== suppressed: 0 bytes in 0 blocks
==38235== Reachable blocks (those to which a pointer was found) are not shown.
==38235== To see them, rerun with: --leak-check=full --show-reachable=yes
==38235==
==38235== For counts of detected and suppressed errors, rerun with: -v
==38235== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Dec 12, 2014

Member

Can you run with --leak-check=full and --show-reachable=yes and paste the output here as well? I sadly can't reproduce this locally :(

Member

alexcrichton commented Dec 12, 2014

Can you run with --leak-check=full and --show-reachable=yes and paste the output here as well? I sadly can't reproduce this locally :(

@rjammala

This comment has been minimized.

Show comment
Hide comment
@rjammala

rjammala Dec 12, 2014

$ valgrind --leak-check=full --show-reachable=yes ./learn
==3771== Memcheck, a memory error detector
==3771== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==3771== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==3771== Command: ./learn
==3771== 
Hello World!
How are you today
==3771== 
==3771== HEAP SUMMARY:
==3771==     in use at exit: 1,184 bytes in 4 blocks
==3771==   total heap usage: 18 allocs, 14 frees, 2,696 bytes allocated
==3771== 
==3771== 32 bytes in 1 blocks are still reachable in loss record 1 of 4
==3771==    at 0x128A12: je_mallocx (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11137F: thread_local::imp::register_dtor::h6d14515a39f84cf203b (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1129E3: thread_local::Key$LT$T$GT$::with::h7241079596358413660 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112C42: io::stdio::with_task_stdout::hafb602ec3975fdc5syg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x115557: io::stdio::println_args::h7f0794513d4f2dfcxDg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1110B7: main::hbd01322dca53aee9eaa (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A22A: rt::start::closure.32122 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FEB: rust_try_inner (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FD5: rust_try (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123BB2: unwind::try::hf2f7fcf7ecc46c43Tyc (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123A8B: task::Task::run::h911f3b3bbb0c433efKb (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A05B: rt::start::hfd264fa826df3608S9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771== 
==3771== 64 bytes in 1 blocks are still reachable in loss record 2 of 4
==3771==    at 0x128A12: je_mallocx (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x111431: thread_local::imp::register_dtor::h6d14515a39f84cf203b (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1129E3: thread_local::Key$LT$T$GT$::with::h7241079596358413660 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112C42: io::stdio::with_task_stdout::hafb602ec3975fdc5syg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x115557: io::stdio::println_args::h7f0794513d4f2dfcxDg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1110B7: main::hbd01322dca53aee9eaa (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A22A: rt::start::closure.32122 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FEB: rust_try_inner (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FD5: rust_try (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123BB2: unwind::try::hf2f7fcf7ecc46c43Tyc (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123A8B: task::Task::run::h911f3b3bbb0c433efKb (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A05B: rt::start::hfd264fa826df3608S9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771== 
==3771== 64 bytes in 1 blocks are still reachable in loss record 3 of 4
==3771==    at 0x128A12: je_mallocx (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112CDD: io::stdio::with_task_stdout::hafb602ec3975fdc5syg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x115557: io::stdio::println_args::h7f0794513d4f2dfcxDg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1110B7: main::hbd01322dca53aee9eaa (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A22A: rt::start::closure.32122 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FEB: rust_try_inner (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FD5: rust_try (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123BB2: unwind::try::hf2f7fcf7ecc46c43Tyc (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123A8B: task::Task::run::h911f3b3bbb0c433efKb (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A05B: rt::start::hfd264fa826df3608S9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x119E35: rt::lang_start::hde2a214462357c7eb9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11117E: main (in /home/rjammalamadaka/Programs/Rust/learn)
==3771== 
==3771== 1,024 bytes in 1 blocks are still reachable in loss record 4 of 4
==3771==    at 0x128A12: je_mallocx (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112222: io::buffered::BufferedWriter$LT$W$GT$::with_capacity::h8206835914802320726 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112D63: io::stdio::with_task_stdout::hafb602ec3975fdc5syg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x115557: io::stdio::println_args::h7f0794513d4f2dfcxDg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1110B7: main::hbd01322dca53aee9eaa (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A22A: rt::start::closure.32122 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FEB: rust_try_inner (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FD5: rust_try (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123BB2: unwind::try::hf2f7fcf7ecc46c43Tyc (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123A8B: task::Task::run::h911f3b3bbb0c433efKb (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A05B: rt::start::hfd264fa826df3608S9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x119E35: rt::lang_start::hde2a214462357c7eb9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771== 
==3771== LEAK SUMMARY:
==3771==    definitely lost: 0 bytes in 0 blocks
==3771==    indirectly lost: 0 bytes in 0 blocks
==3771==      possibly lost: 0 bytes in 0 blocks
==3771==    still reachable: 1,184 bytes in 4 blocks
==3771==         suppressed: 0 bytes in 0 blocks
==3771== 
==3771== For counts of detected and suppressed errors, rerun with: -v
==3771== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)

rjammala commented Dec 12, 2014

$ valgrind --leak-check=full --show-reachable=yes ./learn
==3771== Memcheck, a memory error detector
==3771== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==3771== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==3771== Command: ./learn
==3771== 
Hello World!
How are you today
==3771== 
==3771== HEAP SUMMARY:
==3771==     in use at exit: 1,184 bytes in 4 blocks
==3771==   total heap usage: 18 allocs, 14 frees, 2,696 bytes allocated
==3771== 
==3771== 32 bytes in 1 blocks are still reachable in loss record 1 of 4
==3771==    at 0x128A12: je_mallocx (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11137F: thread_local::imp::register_dtor::h6d14515a39f84cf203b (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1129E3: thread_local::Key$LT$T$GT$::with::h7241079596358413660 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112C42: io::stdio::with_task_stdout::hafb602ec3975fdc5syg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x115557: io::stdio::println_args::h7f0794513d4f2dfcxDg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1110B7: main::hbd01322dca53aee9eaa (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A22A: rt::start::closure.32122 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FEB: rust_try_inner (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FD5: rust_try (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123BB2: unwind::try::hf2f7fcf7ecc46c43Tyc (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123A8B: task::Task::run::h911f3b3bbb0c433efKb (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A05B: rt::start::hfd264fa826df3608S9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771== 
==3771== 64 bytes in 1 blocks are still reachable in loss record 2 of 4
==3771==    at 0x128A12: je_mallocx (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x111431: thread_local::imp::register_dtor::h6d14515a39f84cf203b (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1129E3: thread_local::Key$LT$T$GT$::with::h7241079596358413660 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112C42: io::stdio::with_task_stdout::hafb602ec3975fdc5syg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x115557: io::stdio::println_args::h7f0794513d4f2dfcxDg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1110B7: main::hbd01322dca53aee9eaa (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A22A: rt::start::closure.32122 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FEB: rust_try_inner (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FD5: rust_try (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123BB2: unwind::try::hf2f7fcf7ecc46c43Tyc (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123A8B: task::Task::run::h911f3b3bbb0c433efKb (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A05B: rt::start::hfd264fa826df3608S9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771== 
==3771== 64 bytes in 1 blocks are still reachable in loss record 3 of 4
==3771==    at 0x128A12: je_mallocx (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112CDD: io::stdio::with_task_stdout::hafb602ec3975fdc5syg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x115557: io::stdio::println_args::h7f0794513d4f2dfcxDg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1110B7: main::hbd01322dca53aee9eaa (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A22A: rt::start::closure.32122 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FEB: rust_try_inner (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FD5: rust_try (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123BB2: unwind::try::hf2f7fcf7ecc46c43Tyc (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123A8B: task::Task::run::h911f3b3bbb0c433efKb (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A05B: rt::start::hfd264fa826df3608S9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x119E35: rt::lang_start::hde2a214462357c7eb9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11117E: main (in /home/rjammalamadaka/Programs/Rust/learn)
==3771== 
==3771== 1,024 bytes in 1 blocks are still reachable in loss record 4 of 4
==3771==    at 0x128A12: je_mallocx (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112222: io::buffered::BufferedWriter$LT$W$GT$::with_capacity::h8206835914802320726 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x112D63: io::stdio::with_task_stdout::hafb602ec3975fdc5syg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x115557: io::stdio::println_args::h7f0794513d4f2dfcxDg (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x1110B7: main::hbd01322dca53aee9eaa (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A22A: rt::start::closure.32122 (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FEB: rust_try_inner (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x124FD5: rust_try (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123BB2: unwind::try::hf2f7fcf7ecc46c43Tyc (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x123A8B: task::Task::run::h911f3b3bbb0c433efKb (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x11A05B: rt::start::hfd264fa826df3608S9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771==    by 0x119E35: rt::lang_start::hde2a214462357c7eb9x (in /home/rjammalamadaka/Programs/Rust/learn)
==3771== 
==3771== LEAK SUMMARY:
==3771==    definitely lost: 0 bytes in 0 blocks
==3771==    indirectly lost: 0 bytes in 0 blocks
==3771==      possibly lost: 0 bytes in 0 blocks
==3771==    still reachable: 1,184 bytes in 4 blocks
==3771==         suppressed: 0 bytes in 0 blocks
==3771== 
==3771== For counts of detected and suppressed errors, rerun with: -v
==3771== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Dec 12, 2014

Member

Interesting! It looks like destructors registered with pthread_key_create do not run when the process exits, causing this leak.

Member

alexcrichton commented Dec 12, 2014

Interesting! It looks like destructors registered with pthread_key_create do not run when the process exits, causing this leak.

@rjammala

This comment has been minimized.

Show comment
Hide comment
@rjammala

rjammala Dec 12, 2014

Let me know if you need any more information.

rjammala commented Dec 12, 2014

Let me know if you need any more information.

@huonw

This comment has been minimized.

Show comment
Hide comment
@huonw

huonw Jul 22, 2015

Member

This seems to be resolved, at least the program with println!s has nothing still reachable.

Member

huonw commented Jul 22, 2015

This seems to be resolved, at least the program with println!s has nothing still reachable.

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jul 22, 2015

Member

@huonw did you test on linux? You may have been using the ELF TLS instead of pthread tls. I just built a compiler with --disable-elf-tls and it looks like the leak is still present:

$ valgrind ./foo 
==21255== Memcheck, a memory error detector
==21255== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==21255== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==21255== Command: ./foo
==21255== 
Hello World!
How are you today
==21255== 
==21255== HEAP SUMMARY:
==21255==     in use at exit: 312 bytes in 7 blocks
==21255==   total heap usage: 26 allocs, 19 frees, 2,720 bytes allocated
==21255== 
==21255== LEAK SUMMARY:
==21255==    definitely lost: 0 bytes in 0 blocks
==21255==    indirectly lost: 0 bytes in 0 blocks
==21255==      possibly lost: 0 bytes in 0 blocks
==21255==    still reachable: 312 bytes in 7 blocks
==21255==         suppressed: 0 bytes in 0 blocks
==21255== Rerun with --leak-check=full to see details of leaked memory
==21255== 
==21255== For counts of detected and suppressed errors, rerun with: -v
==21255== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Member

alexcrichton commented Jul 22, 2015

@huonw did you test on linux? You may have been using the ELF TLS instead of pthread tls. I just built a compiler with --disable-elf-tls and it looks like the leak is still present:

$ valgrind ./foo 
==21255== Memcheck, a memory error detector
==21255== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==21255== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==21255== Command: ./foo
==21255== 
Hello World!
How are you today
==21255== 
==21255== HEAP SUMMARY:
==21255==     in use at exit: 312 bytes in 7 blocks
==21255==   total heap usage: 26 allocs, 19 frees, 2,720 bytes allocated
==21255== 
==21255== LEAK SUMMARY:
==21255==    definitely lost: 0 bytes in 0 blocks
==21255==    indirectly lost: 0 bytes in 0 blocks
==21255==      possibly lost: 0 bytes in 0 blocks
==21255==    still reachable: 312 bytes in 7 blocks
==21255==         suppressed: 0 bytes in 0 blocks
==21255== Rerun with --leak-check=full to see details of leaked memory
==21255== 
==21255== For counts of detected and suppressed errors, rerun with: -v
==21255== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
@huonw

This comment has been minimized.

Show comment
Hide comment
@huonw

huonw Jul 22, 2015

Member

Ah, yes, that looks like the difference.

Member

huonw commented Jul 22, 2015

Ah, yes, that looks like the difference.

@rjammala

This comment has been minimized.

Show comment
Hide comment
@rjammala

rjammala Dec 10, 2015

It looks like this is no longer an issue (at least using nightly build of rust (1.7-0-nightly):

]$ valgrind ./learn
==79754== Memcheck, a memory error detector
==79754== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==79754== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==79754== Command: ./learn
==79754==
Hello World!
How are you today
==79754==
==79754== HEAP SUMMARY:
==79754== in use at exit: 0 bytes in 0 blocks
==79754== total heap usage: 4 allocs, 4 frees, 960 bytes allocated
==79754==
==79754== All heap blocks were freed -- no leaks are possible
==79754==
==79754== For counts of detected and suppressed errors, rerun with: -v
==79754== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
[rjammalamadaka@localhost Rust]$ rustc --version
rustc 1.7.0-nightly (81ae8be 2015-12-09)
[rjammalamadaka@localhost Rust]$

rjammala commented Dec 10, 2015

It looks like this is no longer an issue (at least using nightly build of rust (1.7-0-nightly):

]$ valgrind ./learn
==79754== Memcheck, a memory error detector
==79754== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==79754== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==79754== Command: ./learn
==79754==
Hello World!
How are you today
==79754==
==79754== HEAP SUMMARY:
==79754== in use at exit: 0 bytes in 0 blocks
==79754== total heap usage: 4 allocs, 4 frees, 960 bytes allocated
==79754==
==79754== All heap blocks were freed -- no leaks are possible
==79754==
==79754== For counts of detected and suppressed errors, rerun with: -v
==79754== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
[rjammalamadaka@localhost Rust]$ rustc --version
rustc 1.7.0-nightly (81ae8be 2015-12-09)
[rjammalamadaka@localhost Rust]$

@tamird

This comment has been minimized.

Show comment
Hide comment
@tamird

tamird Dec 10, 2015

Contributor

This is probably OK to close then

Contributor

tamird commented Dec 10, 2015

This is probably OK to close then

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Dec 10, 2015

Member

Ah unfortunately as I mentioned earlier this is specifically related to pthread TLS instead of ELF TLS (e.g. really old TLS). I just verified that this is indeed still an issue.

Member

alexcrichton commented Dec 10, 2015

Ah unfortunately as I mentioned earlier this is specifically related to pthread TLS instead of ELF TLS (e.g. really old TLS). I just verified that this is indeed still an issue.

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Apr 27, 2016

Member

Trying this today:

$ ./configure --disable-elf-tls
$ make -j6
$ ./x86_64-unknown-linux-gnu/stage2/bin/rustc learn.rs 
$  valgrind --leak-check=full ./learn
==14462== Memcheck, a memory error detector
==14462== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==14462== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==14462== Command: ./learn
==14462== 
Hello World!
How are you today
==14462== 
==14462== HEAP SUMMARY:
==14462==     in use at exit: 0 bytes in 0 blocks
==14462==   total heap usage: 22 allocs, 22 frees, 2,680 bytes allocated
==14462== 
==14462== All heap blocks were freed -- no leaks are possible
==14462== 
==14462== For counts of detected and suppressed errors, rerun with: -v
==14462== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
$ ./x86_64-unknown-linux-gnu/stage2/bin/rustc --version
rustc 1.10.0-dev (80bff1eea 2016-04-26)

Has this been randomly fixed?

Member

steveklabnik commented Apr 27, 2016

Trying this today:

$ ./configure --disable-elf-tls
$ make -j6
$ ./x86_64-unknown-linux-gnu/stage2/bin/rustc learn.rs 
$  valgrind --leak-check=full ./learn
==14462== Memcheck, a memory error detector
==14462== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==14462== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==14462== Command: ./learn
==14462== 
Hello World!
How are you today
==14462== 
==14462== HEAP SUMMARY:
==14462==     in use at exit: 0 bytes in 0 blocks
==14462==   total heap usage: 22 allocs, 22 frees, 2,680 bytes allocated
==14462== 
==14462== All heap blocks were freed -- no leaks are possible
==14462== 
==14462== For counts of detected and suppressed errors, rerun with: -v
==14462== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
$ ./x86_64-unknown-linux-gnu/stage2/bin/rustc --version
rustc 1.10.0-dev (80bff1eea 2016-04-26)

Has this been randomly fixed?

@rjammala

This comment has been minimized.

Show comment
Hide comment
@rjammala

rjammala Apr 27, 2016

yup, even I disabled elf-tls and it seems to have been fixed.
./configure --disable-elf-tls
$ ./x86_64-unknown-linux-gnu/stage2/bin/rustc --version
rustc 1.10.0-dev (80bff1e 2016-04-26)

@alexcrichton : Can we close this?

rjammala commented Apr 27, 2016

yup, even I disabled elf-tls and it seems to have been fixed.
./configure --disable-elf-tls
$ ./x86_64-unknown-linux-gnu/stage2/bin/rustc --version
rustc 1.10.0-dev (80bff1e 2016-04-26)

@alexcrichton : Can we close this?

@tamird

This comment has been minimized.

Show comment
Hide comment
@tamird

tamird Apr 27, 2016

Contributor

Probably needs a test to confirm it doesn't regress.

Contributor

tamird commented Apr 27, 2016

Probably needs a test to confirm it doesn't regress.

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Apr 27, 2016

Member

No, this is still an issue. The --disable-elf-tls option no longer works (that's a separate issue) and as I mentioned earlier (and earlier) this requires pthread TLS to be used, and by default we use ELF TLS so it's difficult to reproduce.

Running binaries on older systems with a working valgrind should reproduce this.

Member

alexcrichton commented Apr 27, 2016

No, this is still an issue. The --disable-elf-tls option no longer works (that's a separate issue) and as I mentioned earlier (and earlier) this requires pthread TLS to be used, and by default we use ELF TLS so it's difficult to reproduce.

Running binaries on older systems with a working valgrind should reproduce this.

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Apr 27, 2016

Member

Gah! I didn't realize the flag didn't work; I thought I was using pthread TLS.

Member

steveklabnik commented Apr 27, 2016

Gah! I didn't realize the flag didn't work; I thought I was using pthread TLS.

@tamird

This comment has been minimized.

Show comment
Hide comment
@tamird

tamird Apr 27, 2016

Contributor

@alexcrichton can you cross-link to the --disable-elf-tls issue?

Contributor

tamird commented Apr 27, 2016

@alexcrichton can you cross-link to the --disable-elf-tls issue?

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Apr 27, 2016

Member

that'd be #32047

Member

alexcrichton commented Apr 27, 2016

that'd be #32047

@jtsiros

This comment has been minimized.

Show comment
Hide comment
@jtsiros

jtsiros Nov 8, 2016

Not sure if this is was resolved on nightly, but I see a similar issue for a trivial for a simple heap allocation testing using a bunch of Box::new() calls:

valgrind-3.12.0
rustc 1.12.1 (d4f3940 2016-10-19)
Darwin mC02QF11JG8WN 15.6.0 Darwin Kernel Version 15.6.0: Thu Sep 1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64 x86_64

valgrind --leak-check=full --show-reachable=yes target/debug/sandbox
==55274== Memcheck, a memory error detector
==55274== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==55274== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==55274== Command: target/debug/sandbox
==55274==
==55274==
==55274== HEAP SUMMARY:
==55274==     in use at exit: 23,333 bytes in 187 blocks
==55274==   total heap usage: 275 allocs, 88 frees, 29,733 bytes allocated
==55274==
==55274== 112 bytes in 1 blocks are still reachable in loss record 39 of 64
==55274==    at 0x10005C681: malloc (in /usr/local/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==55274==    by 0x10019CD7C: tlv_allocate_and_initialize_for_key (in /usr/lib/system/libdyld.dylib)
==55274==    by 0x10019D52B: tlv_get_addr (in /usr/lib/system/libdyld.dylib)
==55274==    by 0x10000541D: std::sys_common::thread_info::set::h3ee71b197ed00dc8 (in target/debug/sandbox)
==55274==    by 0x100006782: std::rt::lang_start::hca48e539ce72a288 (in target/debug/sandbox)
==55274==    by 0x100001639: main (in target/debug/sandbox)
==55274==
==55274== 2,064 bytes in 1 blocks are possibly lost in loss record 61 of 64
==55274==    at 0x10005C942: malloc_zone_malloc (in /usr/local/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==55274==    by 0x10054EEFD: _objc_copyClassNamesForImage (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x100542182: protocols() (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x100542093: readClass(objc_class*, bool, bool) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x10053FC13: gc_init (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x10054724E: objc_initializeClassPair_internal(objc_class*, char const*, objc_class*, objc_class*) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x100554132: layout_string_create (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x10054283C: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x100542300: copySwiftV1MangledName(char const*, bool) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x1005422E9: copySwiftV1MangledName(char const*, bool) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x1005422E9: copySwiftV1MangledName(char const*, bool) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x1005422E9: copySwiftV1MangledName(char const*, bool) (in /usr/lib/libobjc.A.dylib)
==55274==
==55274== LEAK SUMMARY:
==55274==    definitely lost: 0 bytes in 0 blocks
==55274==    indirectly lost: 0 bytes in 0 blocks
==55274==      possibly lost: 2,064 bytes in 1 blocks
==55274==    still reachable: 112 bytes in 1 blocks
==55274==         suppressed: 21,157 bytes in 185 blocks
==55274==
==55274== For counts of detected and suppressed errors, rerun with: -v
==55274== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 15 from 15)

jtsiros commented Nov 8, 2016

Not sure if this is was resolved on nightly, but I see a similar issue for a trivial for a simple heap allocation testing using a bunch of Box::new() calls:

valgrind-3.12.0
rustc 1.12.1 (d4f3940 2016-10-19)
Darwin mC02QF11JG8WN 15.6.0 Darwin Kernel Version 15.6.0: Thu Sep 1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64 x86_64

valgrind --leak-check=full --show-reachable=yes target/debug/sandbox
==55274== Memcheck, a memory error detector
==55274== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==55274== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==55274== Command: target/debug/sandbox
==55274==
==55274==
==55274== HEAP SUMMARY:
==55274==     in use at exit: 23,333 bytes in 187 blocks
==55274==   total heap usage: 275 allocs, 88 frees, 29,733 bytes allocated
==55274==
==55274== 112 bytes in 1 blocks are still reachable in loss record 39 of 64
==55274==    at 0x10005C681: malloc (in /usr/local/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==55274==    by 0x10019CD7C: tlv_allocate_and_initialize_for_key (in /usr/lib/system/libdyld.dylib)
==55274==    by 0x10019D52B: tlv_get_addr (in /usr/lib/system/libdyld.dylib)
==55274==    by 0x10000541D: std::sys_common::thread_info::set::h3ee71b197ed00dc8 (in target/debug/sandbox)
==55274==    by 0x100006782: std::rt::lang_start::hca48e539ce72a288 (in target/debug/sandbox)
==55274==    by 0x100001639: main (in target/debug/sandbox)
==55274==
==55274== 2,064 bytes in 1 blocks are possibly lost in loss record 61 of 64
==55274==    at 0x10005C942: malloc_zone_malloc (in /usr/local/Cellar/valgrind/3.12.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==55274==    by 0x10054EEFD: _objc_copyClassNamesForImage (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x100542182: protocols() (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x100542093: readClass(objc_class*, bool, bool) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x10053FC13: gc_init (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x10054724E: objc_initializeClassPair_internal(objc_class*, char const*, objc_class*, objc_class*) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x100554132: layout_string_create (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x10054283C: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x100542300: copySwiftV1MangledName(char const*, bool) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x1005422E9: copySwiftV1MangledName(char const*, bool) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x1005422E9: copySwiftV1MangledName(char const*, bool) (in /usr/lib/libobjc.A.dylib)
==55274==    by 0x1005422E9: copySwiftV1MangledName(char const*, bool) (in /usr/lib/libobjc.A.dylib)
==55274==
==55274== LEAK SUMMARY:
==55274==    definitely lost: 0 bytes in 0 blocks
==55274==    indirectly lost: 0 bytes in 0 blocks
==55274==      possibly lost: 2,064 bytes in 1 blocks
==55274==    still reachable: 112 bytes in 1 blocks
==55274==         suppressed: 21,157 bytes in 185 blocks
==55274==
==55274== For counts of detected and suppressed errors, rerun with: -v
==55274== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 15 from 15)
@tschottdorf

This comment has been minimized.

Show comment
Hide comment
@tschottdorf

tschottdorf Mar 13, 2017

Contributor

still repros just like a charm, see below (seting of use-jemalloc doesn't matter, though of course the output varies somewhat). I'm happy to look more into why this is broken, but I'd need some guidance.

  1. apply this diff (adapt if you're not on x86_64_unknown_linux_gnu)
    index f95bcb5..dd93595 100644
    --- a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs
    +++ b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs
    @@ -15,6 +15,7 @@ pub fn target() -> TargetResult {
         base.cpu = "x86-64".to_string();
         base.max_atomic_width = Some(64);
         base.pre_link_args.push("-m64".to_string());
    +    base.has_elf_tls = false;
    
         Ok(Target {
             llvm_target: "x86_64-unknown-linux-gnu".to_string(),
  2. ./x.py build src/libtest --stage 1 --incremental (or whichever you prefer)
  3. */*/stage1/*/rustc ~/learn.rs
  4. valgrind --track-origins=yes --leak-check=full --show-reachable=yes ./learn
  5. find the leaks, plus Conditional jump or move depends on uninitialised value.
use-jemalloc=true (click to view)


valgrind --track-origins=yes --leak-check=full --show-reachable=yes ./learn
==27188== Memcheck, a memory error detector
==27188== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==27188== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==27188== Command: ./learn
==27188==
==27188== Conditional jump or move depends on uninitialised value(s)
==27188==    at 0x119CB1: std::io::stdio::stdout::stdout_init::hde9bb20c74d239a0 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x117D3E: _$LT$std..io..lazy..Lazy$LT$T$GT$$GT$::get::hd42305ba5388eaca (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11A17E: std::io::stdio::_print::h909f88694efb8b49 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E6FF: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F292: std::panicking::try::do_call::h47aca5fe0bc0ca6f (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x124200: __rust_maybe_catch_panic (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F247: std::panicking::try::haf2827ba761d86f4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11B498: std::panic::catch_unwind::hd0e9dc562574f6f9 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F206: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==  Uninitialised value was created by a stack allocation
==27188==    at 0x119C52: std::io::stdio::stdout::stdout_init::hde9bb20c74d239a0 (in /home/tschottdorf/rust-pthread/learn)
==27188==
How are you today
==27188==
==27188== HEAP SUMMARY:
==27188==     in use at exit: 312 bytes in 7 blocks
==27188==   total heap usage: 22 allocs, 15 frees, 3,744 bytes allocated
==27188==
==27188== 8 bytes in 1 blocks are still reachable in loss record 1 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x123F30: _$LT$alloc..raw_vec..RawVec$LT$T$GT$$GT$::with_capacity::h9ac4354317bda4cc (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x124062: collections::slice::_$LT$impl$u20$collections..borrow..ToOwned$u20$for$u20$$u5b$T$u5d$$GT$::to_owned::ha76a6ec29817e7b5 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x123EE1: collections::str::_$LT$impl$u20$collections..borrow..ToOwned$u20$for$u20$str$GT$::to_owned::h471d5925d3705d5e (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1D0: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 32 bytes in 1 blocks are still reachable in loss record 2 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x10E906: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::hf79eb5e1178b3ce0 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11141D: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::haff1cf65b443d42b (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F2B8: std::panicking::panicking::h4bf7d1f6b8817da7 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x1103BA: _$LT$std..sys_common..remutex..ReentrantMutex$LT$T$GT$$GT$::lock::h1f21b2cbcd0ed8ce (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x119E41: _$LT$std..io..stdio..Stdout$u20$as$u20$std..io..Write$GT$::write_fmt::hb0aeab83fe2aee50 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11A1D0: std::io::stdio::_print::h909f88694efb8b49 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E6FF: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F292: std::panicking::try::do_call::h47aca5fe0bc0ca6f (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x124200: __rust_maybe_catch_panic (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F247: std::panicking::try::haf2827ba761d86f4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11B498: std::panic::catch_unwind::hd0e9dc562574f6f9 (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 48 bytes in 1 blocks are still reachable in loss record 3 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x1165E0: _$LT$std..sync..mutex..Mutex$LT$T$GT$$GT$::new::hf4e3619dc58c81a2 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110856: std::thread::Thread::new::ha2a11efc1d6ac4f2 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110B5C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::h188fe40d655e3e09 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1D8: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 48 bytes in 1 blocks are still reachable in loss record 4 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x1100F5: std::sync::condvar::Condvar::new::h4fbbad5b416fb56f (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110860: std::thread::Thread::new::ha2a11efc1d6ac4f2 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110B5C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::h188fe40d655e3e09 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1D8: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 48 bytes in 1 blocks are still reachable in loss record 5 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x10E876: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::h307be15b67cc5cff (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x1117FB: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::hb38a09bf838c22e7 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11E5FD: std::sys_common::thread_info::set::h9bdea53d21fd0ea4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1EF: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 48 bytes in 1 blocks are still reachable in loss record 6 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x10E7E6: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::h0a66dfc1cd407d9b (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x111902: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::state::h517ffedf5ce521c1 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11A156: std::io::stdio::_print::h909f88694efb8b49 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E6FF: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F292: std::panicking::try::do_call::h47aca5fe0bc0ca6f (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x124200: __rust_maybe_catch_panic (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F247: std::panicking::try::haf2827ba761d86f4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11B498: std::panic::catch_unwind::hd0e9dc562574f6f9 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F206: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 80 bytes in 1 blocks are still reachable in loss record 7 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x110896: std::thread::Thread::new::ha2a11efc1d6ac4f2 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110B5C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::h188fe40d655e3e09 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1D8: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== LEAK SUMMARY:
==27188==    definitely lost: 0 bytes in 0 blocks
==27188==    indirectly lost: 0 bytes in 0 blocks
==27188==      possibly lost: 0 bytes in 0 blocks
==27188==    still reachable: 312 bytes in 7 blocks
==27188==         suppressed: 0 bytes in 0 blocks
==27188==
==27188== For counts of detected and suppressed errors, rerun with: -v
==27188== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

use-jemalloc=false (click to view)


==18929== Memcheck, a memory error detector
==18929== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==18929== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==18929== Command: ./learn
==18929==
==18929== Conditional jump or move depends on uninitialised value(s)
==18929==    at 0x1174E1: std::io::stdio::stdout::stdout_init::h8c219ec6edaca9e2 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11556E: _$LT$std..io..lazy..Lazy$LT$T$GT$$GT$::get::h3818fe46065008a9 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x1179AE: std::io::stdio::_print::hb65c73db7e5ba8b4 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF2F: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CAC2: std::panicking::try::do_call::h4af13c61a0885795 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x121A30: __rust_maybe_catch_panic (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CA77: std::panicking::try::h5d0504a555a21656 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118CC8: std::panic::catch_unwind::h8daeb6c836b441af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA36: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==  Uninitialised value was created by a stack allocation
==18929==    at 0x117482: std::io::stdio::stdout::stdout_init::h8c219ec6edaca9e2 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
How are you today
==18929==
==18929== HEAP SUMMARY:
==18929==     in use at exit: 277 bytes in 7 blocks
==18929==   total heap usage: 23 allocs, 16 frees, 3,560 bytes allocated
==18929==
==18929== 5 bytes in 1 blocks are still reachable in loss record 1 of 7
==18929==    at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10CB12: _$LT$alloc..raw_vec..RawVec$LT$T$GT$$GT$::reserve_exact::h4edf8f87d342a05f (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118AE5: std::ffi::c_str::CString::from_vec_unchecked::hdcef4de01dead576 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118A7D: std::ffi::c_str::CString::_new::hc7b7f6376e99eb50 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x1189B5: std::ffi::c_str::CString::new::h31a27631ea3d129f (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E01B: std::thread::Thread::new::hdbde4e93369830a6 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E38C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::hd92ec6def8113f36 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA08: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 24 bytes in 1 blocks are still reachable in loss record 2 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10C016: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::h4cb8adf76f34a8a8 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10EDAD: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::h7268ed135fa874a3 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CAE8: std::panicking::panicking::hf8bff814c3b72c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10DBEA: _$LT$std..sys_common..remutex..ReentrantMutex$LT$T$GT$$GT$::lock::hc072fd20cb222349 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x117671: _$LT$std..io..stdio..Stdout$u20$as$u20$std..io..Write$GT$::write_fmt::ha9551f3ca8d595e4 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x117A00: std::io::stdio::_print::hb65c73db7e5ba8b4 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF2F: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CAC2: std::panicking::try::do_call::h4af13c61a0885795 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x121A30: __rust_maybe_catch_panic (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CA77: std::panicking::try::h5d0504a555a21656 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118CC8: std::panic::catch_unwind::h8daeb6c836b441af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 40 bytes in 1 blocks are still reachable in loss record 3 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x113E10: _$LT$std..sync..mutex..Mutex$LT$T$GT$$GT$::new::h2c7659a20efbd015 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E086: std::thread::Thread::new::hdbde4e93369830a6 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E38C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::hd92ec6def8113f36 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA08: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 40 bytes in 1 blocks are still reachable in loss record 4 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10C136: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::hf9087164760e6dbd (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10F132: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::state::h0545415cf9387211 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x117986: std::io::stdio::_print::hb65c73db7e5ba8b4 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF2F: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CAC2: std::panicking::try::do_call::h4af13c61a0885795 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x121A30: __rust_maybe_catch_panic (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CA77: std::panicking::try::h5d0504a555a21656 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118CC8: std::panic::catch_unwind::h8daeb6c836b441af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA36: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 48 bytes in 1 blocks are still reachable in loss record 5 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10D925: std::sync::condvar::Condvar::new::h9b5a8a20b184aadc (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E090: std::thread::Thread::new::hdbde4e93369830a6 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E38C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::hd92ec6def8113f36 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA08: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 48 bytes in 1 blocks are still reachable in loss record 6 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10C0A6: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::hbf071f63bdfa8db8 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10EE1B: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::ha1974f44b6021a71 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11BE2D: std::sys_common::thread_info::set::hcd1ca419433f28db (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA1F: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 72 bytes in 1 blocks are still reachable in loss record 7 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10E0C6: std::thread::Thread::new::hdbde4e93369830a6 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E38C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::hd92ec6def8113f36 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA08: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== LEAK SUMMARY:
==18929==    definitely lost: 0 bytes in 0 blocks
==18929==    indirectly lost: 0 bytes in 0 blocks
==18929==      possibly lost: 0 bytes in 0 blocks
==18929==    still reachable: 277 bytes in 7 blocks
==18929==         suppressed: 0 bytes in 0 blocks
==18929==
==18929== For counts of detected and suppressed errors, rerun with: -v
==18929== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Contributor

tschottdorf commented Mar 13, 2017

still repros just like a charm, see below (seting of use-jemalloc doesn't matter, though of course the output varies somewhat). I'm happy to look more into why this is broken, but I'd need some guidance.

  1. apply this diff (adapt if you're not on x86_64_unknown_linux_gnu)
    index f95bcb5..dd93595 100644
    --- a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs
    +++ b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs
    @@ -15,6 +15,7 @@ pub fn target() -> TargetResult {
         base.cpu = "x86-64".to_string();
         base.max_atomic_width = Some(64);
         base.pre_link_args.push("-m64".to_string());
    +    base.has_elf_tls = false;
    
         Ok(Target {
             llvm_target: "x86_64-unknown-linux-gnu".to_string(),
  2. ./x.py build src/libtest --stage 1 --incremental (or whichever you prefer)
  3. */*/stage1/*/rustc ~/learn.rs
  4. valgrind --track-origins=yes --leak-check=full --show-reachable=yes ./learn
  5. find the leaks, plus Conditional jump or move depends on uninitialised value.
use-jemalloc=true (click to view)


valgrind --track-origins=yes --leak-check=full --show-reachable=yes ./learn
==27188== Memcheck, a memory error detector
==27188== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==27188== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==27188== Command: ./learn
==27188==
==27188== Conditional jump or move depends on uninitialised value(s)
==27188==    at 0x119CB1: std::io::stdio::stdout::stdout_init::hde9bb20c74d239a0 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x117D3E: _$LT$std..io..lazy..Lazy$LT$T$GT$$GT$::get::hd42305ba5388eaca (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11A17E: std::io::stdio::_print::h909f88694efb8b49 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E6FF: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F292: std::panicking::try::do_call::h47aca5fe0bc0ca6f (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x124200: __rust_maybe_catch_panic (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F247: std::panicking::try::haf2827ba761d86f4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11B498: std::panic::catch_unwind::hd0e9dc562574f6f9 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F206: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==  Uninitialised value was created by a stack allocation
==27188==    at 0x119C52: std::io::stdio::stdout::stdout_init::hde9bb20c74d239a0 (in /home/tschottdorf/rust-pthread/learn)
==27188==
How are you today
==27188==
==27188== HEAP SUMMARY:
==27188==     in use at exit: 312 bytes in 7 blocks
==27188==   total heap usage: 22 allocs, 15 frees, 3,744 bytes allocated
==27188==
==27188== 8 bytes in 1 blocks are still reachable in loss record 1 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x123F30: _$LT$alloc..raw_vec..RawVec$LT$T$GT$$GT$::with_capacity::h9ac4354317bda4cc (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x124062: collections::slice::_$LT$impl$u20$collections..borrow..ToOwned$u20$for$u20$$u5b$T$u5d$$GT$::to_owned::ha76a6ec29817e7b5 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x123EE1: collections::str::_$LT$impl$u20$collections..borrow..ToOwned$u20$for$u20$str$GT$::to_owned::h471d5925d3705d5e (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1D0: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 32 bytes in 1 blocks are still reachable in loss record 2 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x10E906: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::hf79eb5e1178b3ce0 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11141D: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::haff1cf65b443d42b (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F2B8: std::panicking::panicking::h4bf7d1f6b8817da7 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x1103BA: _$LT$std..sys_common..remutex..ReentrantMutex$LT$T$GT$$GT$::lock::h1f21b2cbcd0ed8ce (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x119E41: _$LT$std..io..stdio..Stdout$u20$as$u20$std..io..Write$GT$::write_fmt::hb0aeab83fe2aee50 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11A1D0: std::io::stdio::_print::h909f88694efb8b49 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E6FF: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F292: std::panicking::try::do_call::h47aca5fe0bc0ca6f (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x124200: __rust_maybe_catch_panic (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F247: std::panicking::try::haf2827ba761d86f4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11B498: std::panic::catch_unwind::hd0e9dc562574f6f9 (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 48 bytes in 1 blocks are still reachable in loss record 3 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x1165E0: _$LT$std..sync..mutex..Mutex$LT$T$GT$$GT$::new::hf4e3619dc58c81a2 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110856: std::thread::Thread::new::ha2a11efc1d6ac4f2 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110B5C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::h188fe40d655e3e09 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1D8: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 48 bytes in 1 blocks are still reachable in loss record 4 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x1100F5: std::sync::condvar::Condvar::new::h4fbbad5b416fb56f (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110860: std::thread::Thread::new::ha2a11efc1d6ac4f2 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110B5C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::h188fe40d655e3e09 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1D8: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 48 bytes in 1 blocks are still reachable in loss record 5 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x10E876: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::h307be15b67cc5cff (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x1117FB: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::hb38a09bf838c22e7 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11E5FD: std::sys_common::thread_info::set::h9bdea53d21fd0ea4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1EF: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 48 bytes in 1 blocks are still reachable in loss record 6 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x10E7E6: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::h0a66dfc1cd407d9b (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x111902: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::state::h517ffedf5ce521c1 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11A156: std::io::stdio::_print::h909f88694efb8b49 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E6FF: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F292: std::panicking::try::do_call::h47aca5fe0bc0ca6f (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x124200: __rust_maybe_catch_panic (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11F247: std::panicking::try::haf2827ba761d86f4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x11B498: std::panic::catch_unwind::hd0e9dc562574f6f9 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F206: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== 80 bytes in 1 blocks are still reachable in loss record 7 of 7
==27188==    at 0x129DED: mallocx (jemalloc.c:2173)
==27188==    by 0x110896: std::thread::Thread::new::ha2a11efc1d6ac4f2 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x110B5C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::h188fe40d655e3e09 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10F1D8: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==27188==    by 0x10E739: main (in /home/tschottdorf/rust-pthread/learn)
==27188==
==27188== LEAK SUMMARY:
==27188==    definitely lost: 0 bytes in 0 blocks
==27188==    indirectly lost: 0 bytes in 0 blocks
==27188==      possibly lost: 0 bytes in 0 blocks
==27188==    still reachable: 312 bytes in 7 blocks
==27188==         suppressed: 0 bytes in 0 blocks
==27188==
==27188== For counts of detected and suppressed errors, rerun with: -v
==27188== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

use-jemalloc=false (click to view)


==18929== Memcheck, a memory error detector
==18929== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==18929== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==18929== Command: ./learn
==18929==
==18929== Conditional jump or move depends on uninitialised value(s)
==18929==    at 0x1174E1: std::io::stdio::stdout::stdout_init::h8c219ec6edaca9e2 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11556E: _$LT$std..io..lazy..Lazy$LT$T$GT$$GT$::get::h3818fe46065008a9 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x1179AE: std::io::stdio::_print::hb65c73db7e5ba8b4 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF2F: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CAC2: std::panicking::try::do_call::h4af13c61a0885795 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x121A30: __rust_maybe_catch_panic (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CA77: std::panicking::try::h5d0504a555a21656 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118CC8: std::panic::catch_unwind::h8daeb6c836b441af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA36: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==  Uninitialised value was created by a stack allocation
==18929==    at 0x117482: std::io::stdio::stdout::stdout_init::h8c219ec6edaca9e2 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
How are you today
==18929==
==18929== HEAP SUMMARY:
==18929==     in use at exit: 277 bytes in 7 blocks
==18929==   total heap usage: 23 allocs, 16 frees, 3,560 bytes allocated
==18929==
==18929== 5 bytes in 1 blocks are still reachable in loss record 1 of 7
==18929==    at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10CB12: _$LT$alloc..raw_vec..RawVec$LT$T$GT$$GT$::reserve_exact::h4edf8f87d342a05f (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118AE5: std::ffi::c_str::CString::from_vec_unchecked::hdcef4de01dead576 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118A7D: std::ffi::c_str::CString::_new::hc7b7f6376e99eb50 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x1189B5: std::ffi::c_str::CString::new::h31a27631ea3d129f (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E01B: std::thread::Thread::new::hdbde4e93369830a6 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E38C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::hd92ec6def8113f36 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA08: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 24 bytes in 1 blocks are still reachable in loss record 2 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10C016: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::h4cb8adf76f34a8a8 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10EDAD: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::h7268ed135fa874a3 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CAE8: std::panicking::panicking::hf8bff814c3b72c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10DBEA: _$LT$std..sys_common..remutex..ReentrantMutex$LT$T$GT$$GT$::lock::hc072fd20cb222349 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x117671: _$LT$std..io..stdio..Stdout$u20$as$u20$std..io..Write$GT$::write_fmt::ha9551f3ca8d595e4 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x117A00: std::io::stdio::_print::hb65c73db7e5ba8b4 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF2F: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CAC2: std::panicking::try::do_call::h4af13c61a0885795 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x121A30: __rust_maybe_catch_panic (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CA77: std::panicking::try::h5d0504a555a21656 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118CC8: std::panic::catch_unwind::h8daeb6c836b441af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 40 bytes in 1 blocks are still reachable in loss record 3 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x113E10: _$LT$std..sync..mutex..Mutex$LT$T$GT$$GT$::new::h2c7659a20efbd015 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E086: std::thread::Thread::new::hdbde4e93369830a6 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E38C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::hd92ec6def8113f36 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA08: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 40 bytes in 1 blocks are still reachable in loss record 4 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10C136: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::hf9087164760e6dbd (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10F132: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::state::h0545415cf9387211 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x117986: std::io::stdio::_print::hb65c73db7e5ba8b4 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF2F: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CAC2: std::panicking::try::do_call::h4af13c61a0885795 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x121A30: __rust_maybe_catch_panic (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11CA77: std::panicking::try::h5d0504a555a21656 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x118CC8: std::panic::catch_unwind::h8daeb6c836b441af (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA36: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 48 bytes in 1 blocks are still reachable in loss record 5 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10D925: std::sync::condvar::Condvar::new::h9b5a8a20b184aadc (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E090: std::thread::Thread::new::hdbde4e93369830a6 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E38C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::hd92ec6def8113f36 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA08: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 48 bytes in 1 blocks are still reachable in loss record 6 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10C0A6: _$LT$std..thread..local..os..Key$LT$T$GT$$GT$::get::hbf071f63bdfa8db8 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10EE1B: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::ha1974f44b6021a71 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x11BE2D: std::sys_common::thread_info::set::hcd1ca419433f28db (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA1F: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== 72 bytes in 1 blocks are still reachable in loss record 7 of 7
==18929==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18929==    by 0x10E0C6: std::thread::Thread::new::hdbde4e93369830a6 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10E38C: _$LT$std..thread..Thread$u20$as$u20$std..sys_common..thread_info..NewThread$GT$::new::hd92ec6def8113f36 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10CA08: std::rt::lang_start::h74f5ad66fb152c57 (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==    by 0x10BF69: main (in /home/tschottdorf/rust-nojemalloc/learn)
==18929==
==18929== LEAK SUMMARY:
==18929==    definitely lost: 0 bytes in 0 blocks
==18929==    indirectly lost: 0 bytes in 0 blocks
==18929==      possibly lost: 0 bytes in 0 blocks
==18929==    still reachable: 277 bytes in 7 blocks
==18929==         suppressed: 0 bytes in 0 blocks
==18929==
==18929== For counts of detected and suppressed errors, rerun with: -v
==18929== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

@tschottdorf

This comment has been minimized.

Show comment
Hide comment
@tschottdorf

tschottdorf Mar 13, 2017

Contributor

Oh, btw, the Conditional jump or move depends on uninitialised value(s) is always there (i.e. even when you don't apply the patch). So that's probably new. Isn't this run in CI somewhere?

==31040== Memcheck, a memory error detector
==31040== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==31040== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==31040== Command: ./learn
==31040==
==31040== Conditional jump or move depends on uninitialised value(s)
==31040==    at 0x10EB61: std::io::stdio::stdout::stdout_init::hde9bb20c74d239a0 (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x11DC3E: _$LT$std..io..lazy..Lazy$LT$T$GT$$GT$::get::hd42305ba5388eaca (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x10F02E: std::io::stdio::_print::h909f88694efb8b49 (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x10E6EF: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x113922: std::panicking::try::do_call::h47aca5fe0bc0ca6f (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x124260: __rust_maybe_catch_panic (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x1138D7: std::panicking::try::haf2827ba761d86f4 (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x110956: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x10E729: main (in /home/tschottdorf/rust-pthread/learn)
==31040==  Uninitialised value was created by a stack allocation
==31040==    at 0x10EB02: std::io::stdio::stdout::stdout_init::hde9bb20c74d239a0 (in /home/tschottdorf/rust-pthread/learn)
==31040==
How are you today
==31040==
==31040== HEAP SUMMARY:
==31040==     in use at exit: 0 bytes in 0 blocks
==31040==   total heap usage: 21 allocs, 21 frees, 3,680 bytes allocated
==31040==
==31040== All heap blocks were freed -- no leaks are possible
==31040==
==31040== For counts of detected and suppressed errors, rerun with: -v
==31040== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Contributor

tschottdorf commented Mar 13, 2017

Oh, btw, the Conditional jump or move depends on uninitialised value(s) is always there (i.e. even when you don't apply the patch). So that's probably new. Isn't this run in CI somewhere?

==31040== Memcheck, a memory error detector
==31040== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==31040== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==31040== Command: ./learn
==31040==
==31040== Conditional jump or move depends on uninitialised value(s)
==31040==    at 0x10EB61: std::io::stdio::stdout::stdout_init::hde9bb20c74d239a0 (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x11DC3E: _$LT$std..io..lazy..Lazy$LT$T$GT$$GT$::get::hd42305ba5388eaca (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x10F02E: std::io::stdio::_print::h909f88694efb8b49 (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x10E6EF: learn::main::h86b1088ba10af1af (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x113922: std::panicking::try::do_call::h47aca5fe0bc0ca6f (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x124260: __rust_maybe_catch_panic (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x1138D7: std::panicking::try::haf2827ba761d86f4 (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x110956: std::rt::lang_start::h8c02412f0e1905c4 (in /home/tschottdorf/rust-pthread/learn)
==31040==    by 0x10E729: main (in /home/tschottdorf/rust-pthread/learn)
==31040==  Uninitialised value was created by a stack allocation
==31040==    at 0x10EB02: std::io::stdio::stdout::stdout_init::hde9bb20c74d239a0 (in /home/tschottdorf/rust-pthread/learn)
==31040==
How are you today
==31040==
==31040== HEAP SUMMARY:
==31040==     in use at exit: 0 bytes in 0 blocks
==31040==   total heap usage: 21 allocs, 21 frees, 3,680 bytes allocated
==31040==
==31040== All heap blocks were freed -- no leaks are possible
==31040==
==31040== For counts of detected and suppressed errors, rerun with: -v
==31040== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
@arielb1

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Mar 13, 2017

Contributor

Oh, btw, the Conditional jump or move depends on uninitialised value(s) is always there (i.e. even when you don't apply the patch).

That warning is harmless, and caused by LLVM optimization - see https://bugs.llvm.org//show_bug.cgi?id=23180 .

Contributor

arielb1 commented Mar 13, 2017

Oh, btw, the Conditional jump or move depends on uninitialised value(s) is always there (i.e. even when you don't apply the patch).

That warning is harmless, and caused by LLVM optimization - see https://bugs.llvm.org//show_bug.cgi?id=23180 .

@o01eg

This comment has been minimized.

Show comment
Hide comment
@o01eg

o01eg Mar 13, 2017

Contributor

Can compiler just optimize out condition?

Contributor

o01eg commented Mar 13, 2017

Can compiler just optimize out condition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment