Skip to content

Commit 35e26e9

Browse files
committed
Fix a spuriously tripped assert in select()
The race here happened when a port had its deschedule in select() canceled, but the other chan had already been dropped. This meant that the DISCONNECTED case was hit in abort_selection, but the to_wake cell hadn't been emptied yet (this was done after aborting), causing an assert in abort_selection to trip. To fix this, the to_wake cell is just emptied before abort_selection is called (we know that we're the owner of it already).
1 parent 657e353 commit 35e26e9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: src/libstd/comm/select.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,14 @@ impl Select {
199199
if (*packet).decrement() {
200200
Ok(())
201201
} else {
202+
// Empty to_wake first to avoid tripping an assertion in
203+
// abort_selection in the disconnected case.
204+
let task = (*packet).to_wake.take_unwrap();
202205
(*packet).abort_selection(false);
203206
(*packet).selecting.store(false, SeqCst);
204207
ready_index = i;
205208
ready_id = (*packet).selection_id;
206-
Err((*packet).to_wake.take_unwrap())
209+
Err(task)
207210
}
208211
});
209212

0 commit comments

Comments
 (0)