ReviewOS

zig-utils/zig-js

Test: release bounded recovery reserve across a quiescent host boundary

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

Related: #636, #637, #645, #655 Parent: #480

Problem

Context heap_limit_bytes never publishes a torn object under recovery pressure sets its reserve binding to null and invokes gc() inside the same native evaluation frame that created and touched the reserve graph. Full collection at that point intentionally scans the active native stack conservatively. Stale reserve pointers may therefore keep the graph live even though the JavaScript binding is null.

The result is platform/toolchain dependent: macOS normal and TSan reclaim enough to score complete post-OOM objects, while Linux TSan repeatedly retains the reserve and reports 500/500 post-recovery OOMs. That does not demonstrate a torn object or failed sweep; it disproves the test comment that the in-frame release guarantees reclamation.

Scope

  • Build the live hoard and exact-shape reserve in one evaluation.
  • Return across the host boundary, clear the reserve in a separate evaluation, return again, and collect from the quiescent host frame after stale creation-frame pointers are gone.
  • Keep the hoard rooted, preserve the unchanged 4 MiB cap, require the initial pressure OOM, and score every successfully returned object for complete field/array/string publication.
  • Retain exact full-collection and zero-leak assertions in normal and TSan runs.

No-workaround rules

  • No larger heap cap, reduced hoard, ignored all-OOM result, disabled conservative scanning, forced pointer scrubbing, retry loop, platform skip, or sanitizer exclusion.

Acceptance

  • The corrected witness deterministically observes pressure and at least one complete post-recovery object on macOS and Linux under normal and TSan builds.
  • No torn object is ever published and the 4 MiB cap remains exact.
  • Full units and the fresh Linux shard pass with zero leaks.
9 days ago

Landed 4ad7dd7b (test(gc): make recovery reserve quiescent (#657)). The 4 MiB cap, 50,000-object pressure hoard, 128 exact-shape reserve, 500 publication probes, and all-OOM rejection remain unchanged. Only the lifetime boundary changed: reserve creation/pressure, reserve clearing, and host-side collection now occur across returned evaluation frames.

Local evidence with Zig 0.17.0-dev.1818:

  • focused normal: 1 passed, 0 failed, 0 leaked (1.951 s);
  • focused TSan: 1 passed, 0 failed, 0 leaked (13.390 s);
  • exact TSan shard 3/4 ordering: tests 1-135 passed, including the corrected witness at the formerly failing position 98 (20.348 s). The remainder was stopped after user-owned Home work stretched unrelated tests to 60 seconds; no wall-time claim is made.

Keeping this open for the fresh Linux TSan shard.

9 days ago

Closed by 4ad7dd7b. Fresh Linux confirmation is green in normal unit shard 3 and TSan unit shard 3. The exact 4 MiB cap, pressure OOM, 50,000-object hoard, 128-object reserve, 500 probes, made > 0 oracle, and zero-leak requirement all remained intact; only the invalid same-native-frame reclamation assumption changed.

Sign in to comment on this issue.