ReviewOS

zig-utils/zig-js

No-GIL debugger: make script and statement registries race-free

#314
Closed chris opened this 9 days ago ·
9 days ago

CI: https://github.com/zig-utils/zig-js/actions/runs/29674163787/job/88158274698 Roadmap: #143 Related: #293

Root cause

The no-GIL PR-249 case jit/int-gate-stop-budget.js produced a suppression-free TSan race between:

  • registerParsedDebugScript mutating the shared Context.debug_statement_locations AutoHashMap while a child constructs a dynamic Function; and
  • serviceDebugStatement reading the same map from another child.

The same transaction also mutates debug_scripts and next_debug_script_id unsafely, so fixing only the reported map access would leave duplicate IDs/list corruption latent.

Acceptance

  • Serialize script ID assignment, script-list publication, notify-hook installation/removal, location-map mutation, and all concurrent reads.
  • Keep single-threaded and GIL execution on the lock-free path.
  • Never expose a partially registered script/location record.
  • Add a deterministic multi-thread dynamic-Function witness with exact script-ID uniqueness and result checks.
  • Pass focused normal and suppression-free TSan tests.
  • Re-run the exact jit/int-gate-stop-budget.js TSan witness.
  • Observe a green replacement full CI shard before closing.

Local evidence

  • zig build test -Dtest-filter="debug registry": 3/3 passed.
  • zig build test -Dtest-filter="debug registry" -Dtsan=true: 3/3 passed, suppression-free.
  • zig build threads-test -Dthreads-parallel-js=true -Dthreads-case=jit/int-gate-stop-budget.js -Dtsan=true: 1/1 passed in 26.3 seconds.
  • zig build test -Dtest-filter=inspector: 20/20 passed.
9 days ago

Landed on main as c0ea1fa.

Validation:

  • zig build test -Dtest-filter="debug registry": 3/3 passed
  • zig build test -Dtest-filter="debug registry" -Dtsan=true: 3/3 passed, suppression-free
  • exact no-GIL TSan corpus witness: jit/int-gate-stop-budget.js passed 1/1 in 26.3s
  • zig build test -Dtest-filter=inspector: 20/20 passed

The replacement full-CI result remains the only open acceptance item.

9 days ago

Replacement run 29697559754 passed all four normal unit shards and the suppression-free tsan-parallel-js job on 7650986f. The shared script/location registry race is no longer present.

Sign in to comment on this issue.