ReviewOS

home-lang/home

Bun parity: correct Atomics wait fallback semantics

#325
Closed chris opened this 10 days ago ·
10 days ago

Scope

Port Bun's js/web/atomics.test.ts at corpus position 4087 by correcting the Home compatibility behavior for atomic waits on SharedArrayBuffer-like storage.

Problem

The fallback currently converts every native Atomics.wait() rejection on Home's SharedArrayBuffer-compatible backing into "timed-out". This masks the required immediate "not-equal" result and can also hide invalid typed-array/index errors.

Acceptance criteria

  • return "not-equal" immediately when the current value differs
  • retain "timed-out" for matching values with an elapsed timeout
  • validate waitable typed-array kinds and bounds instead of masking failures
  • preserve structured operation/cause stacks for fallback validation failures
  • focused upstream file passes with zero failures/unsupported tests
  • permanent regression coverage is added

Tracked from #66.

10 days ago

Implemented and pushed to main in 9cf0f953a (fix(atomics): preserve wait outcomes and diagnostics).

The shared Atomics wait-state path now:

  • returns "not-equal" immediately when the observed value differs
  • preserves matching-value timeout behavior
  • normalizes expected values and timeout inputs for Int32Array and BigInt64Array
  • rejects non-waitable typed arrays, non-shared memory, and invalid bounds instead of masking them as timeouts
  • gives waitAsync correct synchronous mismatch/zero-timeout outcomes and asynchronous timeout resolution
  • emits structured ERR_ATOMICS_WAIT errors with operation, typed-array kind, safe index, original cause, and a composed operation/cause stack

Verification:

  • focused js/web/atomics.test.ts: 28 passed, 0 failed, 0 todo, 0 unsupported, 0 allowed-empty
  • positions 4084–4087 together: 4 files, 40 passed, 0 failed, 0 todo, 0 unsupported, 0 allowed-empty
  • permanent gRPC error-stack suite: passed
  • permanent SQL adapter contracts: passed
  • permanent third-party/error-diagnostic suite: passed (53 diagnostic/invariant cases)

This completes the acceptance criteria. Parent tracker: #66.

Sign in to comment on this issue.