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

TcpStream::connect() results in use-of-uninitialized-value #49893

Closed
antoyo opened this issue Apr 12, 2018 · 2 comments
Closed

TcpStream::connect() results in use-of-uninitialized-value #49893

antoyo opened this issue Apr 12, 2018 · 2 comments
Labels
C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@antoyo
Copy link
Contributor

antoyo commented Apr 12, 2018

Hi.
When running the following program:

use std::net::TcpStream;

fn main() {
    let stream = TcpStream::connect("fsf.org:80");
}

If I compile with the flag -Z sanitizer=memory and I run the program, the sanitizer will output the following error:

Uninitialized bytes in __interceptor_getaddrinfo at offset 7 inside [0x701000000010, 8)
==9249==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55c6d6a07757 in std::sys_common::net::lookup_host::h54f2b589f7709f14 /checkout/src/libstd/sys_common/net.rs:169
    #1 0x55c6d6a0adc8 in std::net::lookup_host::h495894627525e525 /checkout/src/libstd/net/mod.rs:192
    #2 0x55c6d6a0adc8 in std::net::addr::resolve_socket_addr::h63a9ed7b59f143af /checkout/src/libstd/net/addr.rs:861
    #3 0x55c6d6a0adc8 in _$LT$str$u20$as$u20$std..net..addr..ToSocketAddrs$GT$::to_socket_addrs::h77d61f3135d300ed /checkout/src/libstd/net/addr.rs:911
    #4 0x55c6d6996324 in _$LT$$RF$$u27$a$u20$T$u20$as$u20$std..net..addr..ToSocketAddrs$GT$::to_socket_addrs::hdbcabfd0f795b49b /checkout/src/libstd/net/addr.rs:928
    #5 0x55c6d69953b8 in std::net::each_addr::hbc122545c1ddb016 /checkout/src/libstd/net/mod.rs:120
    #6 0x55c6d69924f1 in std::net::tcp::TcpStream::connect::h4d0d665e79f451be /checkout/src/libstd/net/tcp.rs:154
    #7 0x55c6d6997273 in test::main::hac3cfabc932bcf2d /test/src/main.rs:4
    #8 0x55c6d69964f7 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hd3da46bdfa33d07c /checkout/src/libstd/rt.rs:74
    #9 0x55c6d6a08c47 in std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::ha4e6f269ebba9c4a /checkout/src/libstd/rt.rs:59
    #10 0x55c6d6a08c47 in _ZN3std9panicking3try7do_call17hdec9e3cbcdfae56cE.llvm.7538121503468158203 /checkout/src/libstd/panicking.rs:305
    #11 0x55c6d6a1847b in __rust_maybe_catch_panic /checkout/src/libpanic_abort/lib.rs:40

SUMMARY: MemorySanitizer: use-of-uninitialized-value /checkout/src/libstd/sys_common/net.rs:169 in std::sys_common::net::lookup_host::h54f2b589f7709f14
Exiting

Rust version: rustc 1.27.0-nightly (056f589fb 2018-04-07)
Thanks to fix this issue.

@pietroalbini pietroalbini added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Apr 12, 2018
@pmarcelll
Copy link
Contributor

I don't see anything wrong with the code, but isn't it a bug actually in getaddrinfo() (which is implemented in C)? The error message is a bit confusing.

@antoyo
Copy link
Contributor Author

antoyo commented Oct 4, 2018

This might be a duplicate of #39610.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants