Skip to content

Commit

Permalink
Fix a spuriously tripped assert in select()
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
alexcrichton committed Jan 24, 2014
1 parent 657e353 commit 35e26e9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libstd/comm/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,14 @@ impl Select {
if (*packet).decrement() {
Ok(())
} else {
// Empty to_wake first to avoid tripping an assertion in
// abort_selection in the disconnected case.
let task = (*packet).to_wake.take_unwrap();
(*packet).abort_selection(false);
(*packet).selecting.store(false, SeqCst);
ready_index = i;
ready_id = (*packet).selection_id;
Err((*packet).to_wake.take_unwrap())
Err(task)
}
});

Expand Down

9 comments on commit 35e26e9

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at alexcrichton@35e26e9

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/select-fix = 35e26e9 into auto

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/select-fix = 35e26e9 merged ok, testing candidate = 327c4dc6

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at alexcrichton@35e26e9

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/select-fix = 35e26e9 into auto

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/select-fix = 35e26e9 merged ok, testing candidate = b0ef2d5

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 35e26e9 Jan 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = b0ef2d5

Please sign in to comment.