Repository navigation
Description
Parent: #480
Blocks: stacksjs/the-settlers-iii-remake#244
Related: #859, #1116, #1118, #1119
Executed bounded-memory failure
A public retained callback repeatedly clones one retained object containing 256 numbers. It creates no per-call closure, checks copied identity and exact contents, uses the default interpreter guard and 64 MiB heap limit, and requests no manual collection.
On the current combined native candidate, it fails with OutOfMemory at callback 7,897. Arena capacity reaches 65,310,093 bytes; at callback 7,501, GC cells occupy only 297,472 bytes after 41 automatic full collections. The no-clone control completes all 10,003 checked numeric callbacks with arena capacity 1,036,680 bytes and 248,528 GC-cell bytes. Its diagnostic host deliberately ends with IncompleteScenario, not a claimed game pass or fabricated replay result.
Executed source identity: base 56ca62c plus tracked combined memory diff SHA256 afc17b57a952a9a8ce0148ff416d22290b68bd22a5cdad162dd84c2c03acfd79. Diagnostic native binary SHA256 35e6562cda25fe1423016180e3de26cf6b664199d17ba04aa56ee229b39fd868. Source, binaries, phase maps, exact logs and receipts are retained under Code/Verification/settlers-retained-replay/native-growth-audit/checkpoint-phase-diagnostic.
Source ownership
- structuredCloneFn serializes into self.arena and never frees the wire buffer after deserialization consumes it.
- Serializer indexes, writer storage and array snapshots use the supplied allocator; when the builtin supplies the Context arena, their nominal cleanup cannot reclaim invocation-local allocations.
- Deserializer.objs grows in self.arena and has no operation cleanup.
Public serialize callers may legitimately own longer-lived wire data, including Worker messages and SharedArrayBuffer manifests. Fix the builtin consumer and operation scratch ownership without changing that public allocator/ownership contract. Escaping strings, property keys, arrays and buffers must own their copied data after wire storage is freed.
Native checkpoint context
The unchanged 5,000-tick game scenario now reaches callback 5,002 and then fails. Native identity wrappers preserve expression nesting and show save, stringify, parse, checkpoint restore, proof/disposal, replay-envelope creation, and verifier input/rules clones all complete; failure is inside decodeState during replay initial restore. Both unchanged-bundle controls and the identity-wrapped run retain the exact original final budget counters. This independent clone defect is useful to fix, but it is not yet established as the sole cause of checkpoint OOM. Full game qualification remains required after integration.
Acceptance
- Add an 8 MiB public retained 256-value clone regression with 1,000 calls and automatic GC only; execute red before changing production.
- Reclaim consumed builtin wire data, serializer scratch and deserializer object-index buffers after each operation, including errors and OOM.
- Preserve graph cycles/aliases, getter reentry, moving roots, arbitrary exact string representations, ArrayBuffer ownership and transfer failure atomicity.
- Preserve versioned wire limits, public caller-owned serialization buffers, Worker behavior, and single-use SAB manifest cleanup.
- Pass focused and affected canonical unit/conformance/moving/shared-realm/TSan gates with honest denominators.
- Rerun the unchanged full 5,000-tick native checkpoint/replay consumer at the original 64 MiB/default guard before claiming adoption.
Activity
chrisbbreuer commentedon Nov 10, 2026
The public 8 MiB retained regression was executed red before production changes and now passes all 1,000 calls with automatic collection only. The focused Context/module run passes 17/17 cases with zero skips, failures or allocator leaks. It covers clone aliases/cycles, canonical strings, getter-requested GC and subsequent compaction, transfer behavior, single-use SAB tokens, allocation failure cleanup, limits and malformed frames.
The candidate gives consumed builtin wire and transfer snapshots operation ownership, frees the deserializer index, and uses authoritative temporary roots for values that can move. Caller-owned serialize buffers and Worker wire ownership retain their existing contracts. Exact commands/logs are retained under Verification/settlers-retained-replay/native-growth-audit/structured-clone-lifetimes; the combined engine source diff is f399a56408e0f7ac68ec54c831743588959621b70f5d3a320fe410c70af16a68 over 56ca62c.
The unchanged full game consumer gets past the former callback-5,002 failure, completing checkpoint restore and entering replay. It reports a replay divergence at callback 5,274. That remains a failing game result. The combined canonical sharded unit gate is running; conformance, shared-realm/TSan and downstream qualification remain outstanding.
fix(clone): release consumed wire and root traversal state
chrisbbreuer commentedon Nov 10, 2026
Pushed c566825d. Consumed clone wire, serializer traversal and deserializer object indexes now have operation ownership with authoritative moving roots. Focused Debug passes 17/17; all-module ThreadSanitizer passes 18/18 without suppressions.
The combined production candidate passed 2,872 full-suite tests with one skip and zero failures/leaks locally. Before/after conformance passes 6,031 cases in both binaries across 39 affected subtrees, with no regressions. Home ABI fixtures pass in Debug, ReleaseSafe and instrumented TSan. Exact commands, source/binary hashes and logs are retained in
Verification/settlers-retained-replay/native-growth-audit/managed-frames-integration; final delivery source equivalence is recorded indelivery-qualified-source.json.Hosted CI on the pushed head still has real failures in cleanup, threaded OOM, the own-key allocation fixture and benchmark metadata contracts. The validator and fixture follow-ups are being qualified separately. The unchanged full native game consumer still diverges at callback 5,119 despite matching simulation and checkpoint checksums. That independent discrepancy is now #1122. No complete engine release, downstream adoption, native presentation, or full replay acceptance is claimed.