about summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2015-03-05 23:03:30 +0200
committerSimonas Kazlauskas <git@kazlauskas.me>2015-03-06 11:22:07 +0200
commit3f94260b0fb2639ba81a5458ec54329e4b860afd (patch)
treeb6d20a006d5873fa3b9bda16eb34ac6a4c5d6f6c /src/libstd/sys/unix/stack_overflow.rs
parent68740b405404a3f885e388c8d31722797d519c30 (diff)
downloadrust-3f94260b0fb2639ba81a5458ec54329e4b860afd.tar.gz
rust-3f94260b0fb2639ba81a5458ec54329e4b860afd.zip
Fix an easy to trigger deadlock in std::io::stdio
Being a person who somehow has taken a liking to premature optimisation, my knee-jerk reaction to
locking in std handles was preamble resembling following snippet:

    let stdout = stdout();
    let lstdout = stdout.lock();
    let stdin = stdin();
    let lstdin = stdin.lock();

and then reading from the locked handle like this:

    let mut letter = [0; 1];
    lstdin.read(&mut letter).unwrap();

As it is now this code will deadlock because the `read` method attempts to lock stdout as well!
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions