ReviewOS

zig-utils/zig-js

Threads corpus: retain completion state on top-level failures

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

Parents: #429, #647 Related: #628

Problem

The PR-249 runner reports the top-level exception and heap budget when a case fails, but not the already-published state of spawned Thread records. For a failure rethrown by Thread.prototype.join, this loses the decisive distinction between the joined worker throwing, a sibling still allocating, and a post-join main-thread failure. Under heap exhaustion, materializing JavaScript Error.stack is itself fallible and the reserved OOM object does not carry the allocation-site stack.

Fresh run 32365143787 demonstrates the gap: semantics/oom-one-thread.js escapes OutOfMemoryError at 201326569 / 201326592 bytes, but the log cannot say whether the hog or a small allocator threw and whether peers had exited.

Required implementation

  • On a top-level threads-corpus evaluation failure, snapshot every Thread record under its completion mutex.
  • Report stable scalar state only: id, done, exited, threw, and join-settlement completion.
  • Preserve any test-shell print buffer before teardown.
  • Allocate nothing and run no JavaScript in this diagnostic path.
  • Keep ordinary passing output byte-identical.

Acceptance

  • A focused failure proves the runner names each spawned record and preserves buffered output.
  • semantics/oom-one-thread.js identifies the exact failing worker/peer state without editing the vendored case.
  • Passing GIL/no-GIL corpus cases and execution inventories remain unchanged.
9 days ago

Implemented in 9736bd74. On the exact pre-fix no-GIL OOM failure, the runner retained all 5 completion records: worker 1 alone had threw=true, while main and the three siblings were done/exited without throws. The report is allocation-free, locks each record while reading its completion scalars, includes already-buffered output, and is emitted only on top-level failure; passing output remains unchanged. Fresh Linux validation: CI run 32369900898.

9 days ago

Closing with direct production validation from run 32369900898: the exact top-level failure retained all five completion records, correctly identifying only worker 1 as throwing while preserving the other completed/exited states. Passing corpus output remains unchanged.

Sign in to comment on this issue.