ReviewOS

zig-utils/zig-js

Conformance: cancel queued test262 agents during reset

#1036
Closed chris opened this 8 days ago ·
8 days ago

Parent: #502 Related: #1032, #1033, #1034, #1035

Executed reproduction

On exact main at d9d1616e1a4505c58fbc51aff5adb831f4b09ed1, a focused standalone agent test pauses the public runnable scheduler at zero, calls the production agent.start, confirms the typed foreground start is queued before entry, and invokes agent.reset on the owning test-host thread.

The bounded observer shows reset cannot finish until runnable capacity is restored:

agent.test.test262 agent cancellation lets reset exit while a start is scheduler-paused...FAIL (TestUnexpectedResult)
0 passed; 0 skipped; 1 failed

reset publishes group.stopping, wakes broadcast and Atomics waiters, and joins every agent. A pre-entry agent cannot observe any group state while blocked in the initial scheduler queue, so test teardown and an intentional zero-capacity policy wait on one another.

Required change

  • Give every Agent record a typed initial-start cancellation handle.
  • agent.reset must cancel pre-entry agents before joining their OS threads.
  • A canceled start must publish the same terminal done and waiter-progress notifications needed by group observers without executing source.
  • A concurrently granted or running agent must retain the existing broadcast/report/Atomics and stop/join semantics.
  • Preserve exact foreground thread, runnable/blocked, stack, waiter, and cancellation accounting under grant-versus-cancel races.

Definition of done

  • The zero-capacity reset reproduction completes before capacity is restored.
  • Canceled agent source does not run and terminal group/waiter notifications are published.
  • Repeated queued cancellations plus running broadcast-park and completion cases balance exact coordinator accounting.
  • Focused normal and unsuppressed TSan tests pass with zero leaks/races.
  • Full unit, runtime-thread audit, and documentation gates pass.
  • #502 records the landed commit and exact evidence.

Guardrails

Do not raise runnable capacity, run agent source outside a scheduler slot, drop a running agent, poll/sleep in reset, weaken test262 rendezvous semantics, or add a corpus-only bypass.

8 days ago

Landed on main in 1424aa2.

Every test262 Agent record now owns a typed initial-start cancellation edge. Reset publishes group stop state, wakes broadcast and Atomics waiters, cancels every queued start before joining any handle, and lets canceled threads publish terminal group/waiter notifications without executing source. Granted and running agents retain the existing broadcast, report, Atomics, completion, and join behavior.

Validation:

  • pre-fix bounded reproduction: reset blocked until runnable capacity was restored
  • post-fix zero-capacity reproduction: reset finishes before capacity restoration
  • eight repeated queued agents: source runs 0 times and exact live/runnable/blocked/stack/waiter/cancellation accounting balances
  • running broadcast-park and ordinary-completion cases: pass with cancellation count unchanged
  • focused standalone normal tests: 3/3 pass
  • focused standalone unsuppressed TSan tests: 3/3 pass, zero races
  • final full unit suite: 2,579 passed; 1 skipped; 0 failed; 0 leaked
  • zig build -j1: pass
  • runtime-thread audit: 6 production sites, 155 reviewed test-only spawns
  • docs link check: 378 files pass
  • test262 corpus cases/flips: not measured because the pinned corpus is unavailable in this checkout

Sign in to comment on this issue.