fix(tasks): same-instant sleeper wake order is spawn-order, not id-order (#535)#536
Merged
Merged
Conversation
…der (#535) sched_wake_sleepers woke due sleepers in ascending handle-id order, but ids come from a rotating next-fit cursor — once slots recycle (#530), the tie-break encoded the process's whole allocation history, so two identical seeded runs in one process could interleave differently. Surfaced by liferaft's M4 fault-injection gate: an in-sweep violation failed to reproduce standalone (verified=0). Tasks now carry a monotonic spawn_seq (main = 0) and same-instant wakes order by it — a pure function of the run. Red/green: a wraparound-straddling sleeper race (ids 254,255,1) observed abc/cab pre-fix, identical post-fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #535
The bug
sched_wake_sleepersused ascending handle id as the same-instant tie-break. Handle ids come from a rotating next-fit cursor, so with #530's slot recycling the tie-break encoded the process's entire allocation history — two identical seeded runs in one process could interleave differently. Surfaced by liferaft's M4 fault-injection gate: a violation found in-sweep failed to reproduce standalone (verified=0), breaking the DST's re-run-to-verify contract.The fix
Tasks carry a monotonic
spawn_seq(scheduler counter; main is 0); same-instant wakes order by it. Spawn order is a pure function of the run, independent of where the slot cursor happens to be.Tests
tests/test_task_sleep_order.eigs: a 3-sleeper same-instant race observed twice in one process, with the slot cursor marched to straddle the 255-slot wraparound in between (racer ids 254, 255, 1). Pre-fix:first=abc second=cab. Post-fix: identical. liferaft's fault-injection verify flips toverified=1against this build.Validation
detect_leaks=1: 2706/2706, leak tally 0🤖 Generated with Claude Code