You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::thread;
use std::sync::mpsc;
use std::time::Duration;
fn main() {
let (tx, rx) = mpsc::channel::<u32>();
let r_handle = thread::spawn(move || {
match rx.recv_timeout(Duration::from_secs(10)){
Err(mpsc::RecvTimeoutError::Timeout) => {}
_ => assert!(false),
}
// next line panics every time.
rx.recv_timeout(Duration::from_secs(10)).unwrap();
});
let t_handle = thread::spawn(move || {
thread::sleep(Duration::from_secs(2));
let _ = tx.clone();
thread::sleep(Duration::from_secs(10));
});
r_handle.join().unwrap();
t_handle.join().unwrap();
}
receiver calls recv_timeout
sender clone itself
recv_timeout returns timeout
receiver calls recv_timeout the second time
boom!
This is what I know, when sender calls clone, it will call inherit_blocker, and then change to_wake in it. The first recv_timeout returns timeout, when the second recv_timeout is called, it will panic in decrement in shared.rs because it needs to check that to_wake equals 0.
The text was updated successfully, but these errors were encountered:
rustc 1.25.0-nightly (73ac5d6a8 2018-01-11)
receiver
callsrecv_timeout
sender
clone itselfrecv_timeout
returns timeoutreceiver
callsrecv_timeout
the second timeThis is what I know, when
sender
calls clone, it will callinherit_blocker
, and then changeto_wake
in it. The firstrecv_timeout
returnstimeout
, when the secondrecv_timeout
is called, it will panic indecrement
inshared.rs
because it needs to check thatto_wake
equals 0.The text was updated successfully, but these errors were encountered: