]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #24029 - nagisa:print-locking, r=alexcrichton
authorbors <bors@rust-lang.org>
Wed, 8 Apr 2015 19:03:09 +0000 (19:03 +0000)
committerbors <bors@rust-lang.org>
Wed, 8 Apr 2015 19:03:09 +0000 (19:03 +0000)
write_fmt calls write for each formatted field. The default implementation of write_fmt is used,
which will call write on not-yet-locked stdout (and write locking after), therefore making print!
in multithreaded environment still interleave contents of two separate prints.

I’m not sure whether we want to do this change, though, because it has the same deadlock hazard which we tried to avoid by not locking inside write_fmt itself (see [this comment](https://github.com/rust-lang/rust/blob/80def6c2447d23a624e611417f24cf0ab2a5a676/src/libstd/io/stdio.rs#L267)).

Spotted on [reddit].

cc @alexcrichton

[reddit]: http://www.reddit.com/r/rust/comments/31comh/println_with_multiple_threads/


Trivial merge