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

Strange leak on env::var #41027

Closed
lu-zero opened this issue Apr 2, 2017 · 7 comments
Closed

Strange leak on env::var #41027

lu-zero opened this issue Apr 2, 2017 · 7 comments
Labels
A-sanitizers Area: Sanitizers for correctness and code quality. C-bug Category: This is a bug.

Comments

@lu-zero
Copy link
Contributor

lu-zero commented Apr 2, 2017

RUSTFLAGS="-Z sanitizer=memory" cargo run

error: failed to run custom build command for `kernel32-sys v0.2.2`
process didn't exit successfully: `/usr/src/rust/x264-rs/target/debug/build/kernel32-sys-9b6c3463a8ee3470/build-script-build` (exit code: 77)
--- stderr
==474==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55e4231f0f80 in _$LT$core..result..Result$LT$T$C$$u20$E$GT$$GT$::unwrap::hbaca9e4c708f1a9a /checkout/src/libcore/result.rs:736
    #1 0x55e42320a4cb in build::link::h780aaf497d81ebf3 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-build-0.1.1/src/lib.rs:5
    #2 0x55e4231e8dc7 in build_script_build::main::hfb4f27f7ca8814c9 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/kernel32-sys-0.2.2/build.rs:5
    #3 0x55e423216175 in core::ops::FnOnce::call_once<fn(),()> /checkout/src/libcore/ops.rs:2606
    #4 0x55e423216175 in std::panicking::try::do_call::h689a21caeeef92aa /checkout/src/libstd/panicking.rs:454
    #5 0x55e42329ac0a in __rust_maybe_catch_panic /checkout/src/libpanic_unwind/lib.rs:98
    #6 0x55e42321695a in std::panicking::try<(),fn()> /checkout/src/libstd/panicking.rs:433
    #7 0x55e42321695a in std::panic::catch_unwind<fn(),()> /checkout/src/libstd/panic.rs:361
    #8 0x55e42321695a in std::rt::lang_start::hf63d494cb7dd034c /checkout/src/libstd/rt.rs:57
    #9 0x55e4231e8e39 in main (/usr/src/rust/x264-rs/target/debug/build/kernel32-sys-9b6c3463a8ee3470/build-script-build+0x9e39)
    #10 0x7f7f9fbd7720 in __libc_start_main (/lib64/libc.so.6+0x20720)
    #11 0x55e4231e8c88 in _start (/usr/src/rust/x264-rs/target/debug/build/kernel32-sys-9b6c3463a8ee3470/build-script-build+0x9c88)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /checkout/src/libcore/result.rs:736 in _$LT$core..result..Result$LT$T$C$$u20$E$GT$$GT$::unwrap::hbaca9e4c708f1a9a

All this on linux, using the latest nightly.

@sfackler
Copy link
Member

sfackler commented Apr 3, 2017

What does this have to do with env::var? It doesn't seem to be mentioned in that output.

@lu-zero
Copy link
Contributor Author

lu-zero commented Apr 3, 2017

line 5 is the call to env::var.

@arthurprs
Copy link
Contributor

Do you have a test code to reproduce it?

@lu-zero
Copy link
Contributor Author

lu-zero commented Apr 5, 2017

test.rs:

fn main(){
    let cmd = std::env::var_os("RUSTC");
    println!("{:?}", cmd);
}

Output:

cielo x264-rs (master)# rustc -Z sanitizer=memory test.rs
cielo x264-rs (master)# ./test
==3102==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55ab16e331af in _$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..fmt..Debug$GT$::fmt::h802b88056fe70792 (/usr/src/rust/x264-rs/test+0xb1af)
    #1 0x55ab16ec5e85 in core::fmt::write::h8ce42890c1b80a07 /checkout/src/libcore/fmt/mod.rs:931
    #2 0x55ab16eb41af in std::io::Write::write_fmt<std::io::stdio::StdoutLock> /checkout/src/libstd/io/mod.rs:1027
    #3 0x55ab16eb41af in _$LT$std..io..stdio..Stdout$u20$as$u20$std..io..Write$GT$::write_fmt::ha0edfaf608769622 /checkout/src/libstd/io/stdio.rs:460
    #4 0x55ab16eb486f in std::io::stdio::_print::h87ad81c40c1d9727 /checkout/src/libstd/io/stdio.rs:680
    #5 0x55ab16e33da8 in test::main::hb5b0b056a2b1b3fc (/usr/src/rust/x264-rs/test+0xbda8)
    #6 0x55ab16ebbda5 in core::ops::FnOnce::call_once<fn(),()> /checkout/src/libcore/ops.rs:2606
    #7 0x55ab16ebbda5 in std::panicking::try::do_call::h689a21caeeef92aa /checkout/src/libstd/panicking.rs:454
    #8 0x55ab16ec397a in __rust_maybe_catch_panic /checkout/src/libpanic_unwind/lib.rs:98
    #9 0x55ab16ebc58a in std::panicking::try<(),fn()> /checkout/src/libstd/panicking.rs:433
    #10 0x55ab16ebc58a in std::panic::catch_unwind<fn(),()> /checkout/src/libstd/panic.rs:361
    #11 0x55ab16ebc58a in std::rt::lang_start::hf63d494cb7dd034c /checkout/src/libstd/rt.rs:57
    #12 0x55ab16e33eaf in main (/usr/src/rust/x264-rs/test+0xbeaf)
    #13 0x7f8d6b60f720 in __libc_start_main (/lib64/libc.so.6+0x20720)
    #14 0x55ab16e31a58 in _start (/usr/src/rust/x264-rs/test+0x9a58)

SUMMARY: MemorySanitizer: use-of-uninitialized-value (/usr/src/rust/x264-rs/test+0xb1af) in _$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..fmt..Debug$GT$::fmt::h802b88056fe70792
Exiting

Same outcome for RUSTC set and unset.

@tbu-
Copy link
Contributor

tbu- commented Apr 19, 2017

Pattern-matching on cmd and cmd.is_some() also trigger it.

@Mark-Simulacrum Mark-Simulacrum added the A-sanitizers Area: Sanitizers for correctness and code quality. label Jun 20, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@lu-zero
Copy link
Contributor Author

lu-zero commented Sep 28, 2018

The problem is still here:

==11962==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x559425363a3e in _$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..fmt..Debug$GT$::fmt::h4b1f37077daa7a53 (/tmp/test+0xaa3e)
    #1 0x5594253da9c1 in core::fmt::Formatter::run::hb94f209be4566339 /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libcore/fmt/mod.rs:1103:8
    #2 0x5594253da9c1 in core::fmt::write::h616689ac84e1a181 /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libcore/fmt/mod.rs:1050
    #3 0x5594253c5dba in std::io::Write::write_fmt::hb8965c5d2ae4b514 /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/io/mod.rs:1139:14
    #4 0x5594253c5dba in _$LT$std..io..stdio..Stdout$u20$as$u20$std..io..Write$GT$::write_fmt::h6c417dd4a815f83a /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/io/stdio.rs:464
    #5 0x5594253c6d90 in std::io::stdio::print_to::_$u7b$$u7b$closure$u7d$$u7d$::hdaa16d922a855dbb /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/io/stdio.rs:694:8
    #6 0x5594253c6d90 in _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::try_with::hb14290590622978c /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/thread/local.rs:294
    #7 0x5594253c5f84 in std::io::stdio::print_to::ha0da5046fa9c3b6a /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/io/stdio.rs:688:17
    #8 0x5594253c5f84 in std::io::stdio::_print::h800c8e7b04169604 /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/io/stdio.rs:709
    #9 0x559425363f10 in test::main::hcf302dac3ad452a9 (/tmp/test+0xaf10)
    #10 0x5594253649b7 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h4a9b03456cc5fd09 (/tmp/test+0xb9b7)
    #11 0x5594253ced92 in std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::h2fa83434b65add1b /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/rt.rs:59:12
    #12 0x5594253ced92 in _ZN3std9panicking3try7do_call17hd2b5f35b09cfe11fE.llvm.3794404441972262337 /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/panicking.rs:310
    #13 0x5594253d76b9 in __rust_maybe_catch_panic /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libpanic_unwind/lib.rs:102:7
    #14 0x5594253beae5 in std::panicking::try::h7e30ff9eb6dacc39 /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/panicking.rs:289:12
    #15 0x5594253beae5 in std::panic::catch_unwind::h088588b005d89c90 /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/panic.rs:392
    #16 0x5594253beae5 in std::rt::lang_start_internal::hfc67e81213c1ae30 /rustc/8876906867b2db3c7177d69dd020c40d89177f86/src/libstd/rt.rs:58
    #17 0x559425364955 in std::rt::lang_start::h02d780a2abb945b7 (/tmp/test+0xb955)
    #18 0x559425363fd5 in main (/tmp/test+0xafd5)
    #19 0x7f9e04e0efaf in __libc_start_main /var/tmp/portage/sys-libs/glibc-2.26-r7/work/glibc-2.26/csu/../csu/libc-start.c:308
    #20 0x559425362449 in _start (/tmp/test+0x9449)

SUMMARY: MemorySanitizer: use-of-uninitialized-value (/tmp/test+0xaa3e) in _$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..fmt..Debug$GT$::fmt::h4b1f37077daa7a53
Exiting
cielo tmp # rustc --version
rustc 1.30.0-nightly (887690686 2018-09-27)

@lu-zero
Copy link
Contributor Author

lu-zero commented Oct 3, 2018

Duplicate of #39610

@lu-zero lu-zero closed this as completed Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sanitizers Area: Sanitizers for correctness and code quality. C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants