Parents: #493, #486 Related: #854, #490
Problem
collectGcAggregatesQuiescent traverses nested exnref payloads with
std.AutoHashMapUnmanaged(*WasmException, void). JavaScript can construct wide
and cyclic WebAssembly exception graphs, retain them through globals/tables/
wrappers, and trigger host collection. Zig's default pointer context has
predictable placement, so allocation history and graph shape can amplify this
quiescent collector before sweep.
#854 bounded exception externref root deduplication only and explicitly left
Wasm GC aggregate collection out of scope.
Required design
- Replace the default pointer set with a lazy exact exception-identity index seeded from secure host entropy, with no deterministic/address/time fallback.
- Publish the context only after the first backing allocation succeeds. Entropy or allocation failure must leave an empty, retryable index.
- Keep exception traversal iterative, exact, cycle-safe, and allocation-failure atomic. Any mark-phase failure must perform no aggregate sweep.
- Preserve nested payload reachability, wrapper roots, globals/tables/active and external roots, cross-instance ownership, mark epochs, and reclamation.
- Do not add a mutable non-atomic exception mark epoch: exception references may cross instance graphs, so independent collections must not race on shared exception state.
No-workaround rules
- No exception/tag/payload caps, rejected graphs, skipped edges, hash-only equality, predictable fallback seed, quadratic scan, recursive traversal, leaked scratch state, partial sweep, global mutable seed, or weakened tests.
Acceptance
- A deterministic legacy pointer collision family disperses under the keyed context with exact lookup/removal.
- Entropy failure and first-allocation failure publish no context/table and exact retry succeeds.
- Wide/deep/cyclic nested exception graphs terminate and retain every reachable aggregate; unreachable aggregates reclaim exactly.
- Exhaustive OOM tests prove mark failure performs no sweep and retry preserves the existing reclamation result.
- Focused collection/exception tests pass in Debug, ReleaseSafe, and TSan.
- Wasm API/spec and GC lifetime gates, threadfuzz, full units, public C API, and pinned private ABI audits/runtime pass with exact linked evidence.