Skip to content

Commit

Permalink
Fix nondeterministic bug in RecvSelection::deinit
Browse files Browse the repository at this point in the history
Using Arc::ptr_eq on trait object pointers can fail unpredictably
because of rust-lang/rust#46139.

This can prevent a Hook from being removed when its RecvSelection is
de-inited, which makes it incorrectly push Tokens to a queue owned by a
Selector that no longer exists.

This may be the cause of zesterer#44.
  • Loading branch information
mbrubeck committed Feb 7, 2021
1 parent 0c5ee68 commit cdb4145
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<'a, T> Selector<'a, T> {
let hook: Arc<Hook<U, dyn Signal>> = hook;
wait_lock(&self.receiver.shared.chan)
.waiting
.retain(|s| !Arc::ptr_eq(s, &hook));
.retain(|s| s.signal().as_ptr() != hook.signal().as_ptr());
// If we were woken, but never polled, wake up another
if !self.received
&& hook
Expand Down

0 comments on commit cdb4145

Please sign in to comment.