Skip to content

Commit cdb4145

Browse files
committed
Fix nondeterministic bug in RecvSelection::deinit
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.
1 parent 0c5ee68 commit cdb4145

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl<'a, T> Selector<'a, T> {
282282
let hook: Arc<Hook<U, dyn Signal>> = hook;
283283
wait_lock(&self.receiver.shared.chan)
284284
.waiting
285-
.retain(|s| !Arc::ptr_eq(s, &hook));
285+
.retain(|s| s.signal().as_ptr() != hook.signal().as_ptr());
286286
// If we were woken, but never polled, wake up another
287287
if !self.received
288288
&& hook

0 commit comments

Comments
 (0)