fix(sched): closed the kill-before-block race in all blocking paths - #135
Open
FlareCoding wants to merge 1 commit into
Open
fix(sched): closed the kill-before-block race in all blocking paths#135FlareCoding wants to merge 1 commit into
FlareCoding wants to merge 1 commit into
Conversation
|
Current version of PR was reviewed by /review-bugbot on Jul 27, 20:32 PDT. It flagged 0 findings. Bugbot on commit |
FlareCoding
force-pushed
the
pr/sched-block-protocol
branch
from
July 28, 2026 04:04
aa0aff5 to
dcc3660
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit dcc3660. Configure here.
force_wake_for_kill only affects tasks already sleeping or BLOCKED, so kills landing during block entry were lost until natural wakeup, or forever for untimed waits. Blocking paths now publish BLOCKED, re-check the kill behind a paired fence, and unwind instead of sleeping; poll's bespoke version of this pattern moved into sched as the shared protocol. Co-authored-by: Cursor <cursoragent@cursor.com>
FlareCoding
force-pushed
the
pr/sched-block-protocol
branch
from
July 28, 2026 05:48
dcc3660 to
520abb2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
force_wake_for_killonly acts on tasks already sleeping or BLOCKED, so a kill landing while the victim was still entering a block was silently lost — delayed until natural wakeup for sleeps, or until an unrelated wake for futexes. This is the root cause of the kill-suite CI flakes.sched-owned protocol —prepare_to_block_task/block_task_interrupted_by_kill/cancel_block_task— adopted by the interruption-capable sites (sleep, futex, poll).poll_waitalready hand-rolled exactly this pattern; its bespoke copy is deleted in favor of the shared one, which also adds the store-load fence pairing the hand-rolled version lacked.wait()now uses the atomic-release state transition and both docs state the contract honestly. Await_killablevariant plus caller audit is explicit follow-up work.kill_before_sleep_aborts_sleep) fails on the unfixed kernel at exactly the 5 s natural expiry and passes with the fix; full suite 510/510 across repeated runs on both architectures.Note
High Risk
Changes core scheduler blocking, kill delivery, and synchronization primitives (sleep, futex, poll); incorrect fencing or unwind logic could cause lost wakeups, stuck tasks, or spurious EINTR.
Overview
Fixes a race where
force_wake_for_killcould miss a task still entering a block, so kills were delayed until natural wakeup (or unrelated wakes). The scheduler now owns a shared prepare → kill-check → cancel blocking protocol with SEQ_CST fences pairingforce_wake_for_killandblock_task_interrupted_by_kill.Sleep, futex wait, and
poll_waitadopt that protocol: they unwind timers/waiters and return without yielding when a kill is seen at the commit point.poll_waitdrops its local abort helper in favor of the sharedcancel_block_task.sync::waitonly switches to atomicprepare_to_block_task; docs state it is not kill-interruptible without caller loops onis_kill_pending().Tests use wall-clock spin timeouts and
wait_until_blockedinstead ofbrief_delay, plus a newkill_before_sleep_aborts_sleepregression for pre-enqueue kills.Reviewed by Cursor Bugbot for commit 520abb2. Bugbot is set up for automated code reviews on this repo. Configure here.