Skip to content

Reading from stdin with libuv on separate task fails on windows #10645

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

Closed
luqmana opened this issue Nov 25, 2013 · 0 comments · Fixed by #10646
Closed

Reading from stdin with libuv on separate task fails on windows #10645

luqmana opened this issue Nov 25, 2013 · 0 comments · Fixed by #10646
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-windows Operating system: Windows

Comments

@luqmana
Copy link
Member

luqmana commented Nov 25, 2013

foo.rs:

use std::io;

fn main() {
    do spawn {
        let b = io::stdin().read_byte().unwrap();
        println!("Got: {}", b as char);
    }
}
$ rustc.exe foo.rs
$ foo.exe
task '<unnamed>' failed at 'stream alloc_cb called more than once', C:\MinGW\msys\1.0\home\Luqman\rust\src\libstd\option.rs:113
task '<main>' failed at 'killed by linked failure', C:\MinGW\msys\1.0\home\Luqman\rust\src\libstd\rt\kill.rs:639

Adding #[no_uv] makes it works as expected:

$ foo.exe
a
Got: a

Ping @alexcrichton

bors added a commit that referenced this issue Nov 25, 2013
This is a behavioral difference in libuv between different platforms in
different situations. It turns out that libuv on windows will immediately
allocate a buffer instead of waiting for data to be ready. What this implies is
that we must have our custom data set on the handle before we call
uv_read_start.

I wish I knew of a way to test this, but this relies to being on the windows
platform *and* reading from a true TTY handle which only happens when this is
actually attached to a terminal. I have manually verified this works.

Closes #10645
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant