-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Race condition in task communication causes deadlocks #15761
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
Comments
It seems that the extern crate time;
use std::io::IoResult;
use std::io::timer::Timer;
use std::sync::Future;
fn repro() -> IoResult<()> {
let (tx, rx): (SyncSender<&'static str>, Receiver<&'static str>) = sync_channel(3);
let mut f = Future::spawn(proc() {
rx.recv();
rx.recv();
Ok(())
});
tx.try_send("zomg").unwrap();
tx.try_send("hi2u").unwrap();
f.get()
}
pub fn main() {
let mut i = 0u;
loop {
i += 1;
println!("starting iter {}; {}", i, time::precise_time_ns());
repro().unwrap();
}
} |
Removing Future deadlocks as well: extern crate time;
use std::io::IoResult;
use std::io::timer::Timer;
use std::sync::Future;
fn repro() -> IoResult<()> {
let (tx1, rx1): (SyncSender<&'static str>, Receiver<&'static str>) = sync_channel(3);
let (tx2, rx2): (SyncSender<&'static str>, Receiver<&'static str>) = sync_channel(3);
spawn(proc() {
rx1.recv();
tx2.try_send("pong").unwrap();
});
tx1.try_send("ping").unwrap();
rx2.recv();
Ok(())
}
pub fn main() {
let mut i = 0u;
loop {
i += 1;
println!("starting iter {}; {}", i, time::precise_time_ns());
repro().unwrap();
}
} |
It seems that |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Jul 18, 2014
This branch of try_send() just forgot to wake up any receiver waiting for data. Closes rust-lang#15761
bors
added a commit
that referenced
this issue
Jul 20, 2014
This branch of try_send() just forgot to wake up any receiver waiting for data. Closes #15761
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Repro:
The text was updated successfully, but these errors were encountered: