Skip to content

fix(tasks): same-instant sleeper wake order is spawn-order, not id-order (#535)#536

Merged
InauguralPhysicist merged 1 commit into
mainfrom
sleeper-wake-spawn-order
Jul 10, 2026
Merged

fix(tasks): same-instant sleeper wake order is spawn-order, not id-order (#535)#536
InauguralPhysicist merged 1 commit into
mainfrom
sleeper-wake-spawn-order

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

Closes #535

The bug

sched_wake_sleepers used 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 to verified=1 against this build.

Validation

  • Full suite, release: 2706/2706
  • Full suite, ASan + detect_leaks=1: 2706/2706, leak tally 0

🤖 Generated with Claude Code

…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>
@InauguralPhysicist InauguralPhysicist merged commit 54364ec into main Jul 10, 2026
17 checks passed
@InauguralPhysicist InauguralPhysicist deleted the sleeper-wake-spawn-order branch July 10, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

task layer: same-instant sleeper wake order depends on handle IDs — interleaving isn't a pure function of the program+seed once slots recycle

1 participant