Skip to content

green: Fix a scheduler assertion on yielding #12818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libgreen/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,20 @@ impl Scheduler {
}

pub fn maybe_yield(mut ~self, cur: ~GreenTask) {
// It's possible for sched tasks to possibly call this function, and it
// just means that they're likely sending on channels (which
// occasionally call this function). Sched tasks follow different paths
// when executing yield_now(), which may possibly trip the assertion
// below. For this reason, we just have sched tasks bail out soon.
//
// Sched tasks have no need to yield anyway because as soon as they
// return they'll yield to other threads by falling back to the event
// loop. Additionally, we completely control sched tasks, so we can make
// sure that they never execute more than enough code.
if cur.is_sched() {
return cur.put_with_sched(self)
}

// The number of times to do the yield check before yielding, chosen
// arbitrarily.
rtassert!(self.yield_check_count > 0);
Expand Down