interp: release execution heaps on allocation failure

This commit is contained in:
dev committed 2026-10-10 16:21:10 +03:00
1 parent 0387405d48
commit fb80413b37
4 files changed
+130 -3

No files matched your search

+51
View File
@@ -120,3 +120,54 @@ attach for read-only stack inspection was rejected by the host's ptrace policy.
Q-060 remains open until the traversal/lifetime audit and full validation have
terminal evidence. Q-059's [compiler inventory](type-traversal-inventory.md)
is now resolved; the earlier statements about its open query paths are historical.
## Closing runtime paths and error-exit cleanup
The production path inventory covers verified interpreter state, not arbitrary
fabricated host values. Arrays/aggregates have finite materialized structure;
backing-cell and closed-graph cycles use the copier's forwarding maps.
| Path | Handling |
|---|---|
| Zero construction, storage/SSA copying | Explicit pending-sibling continuations; no recursive payload descent. |
| Collector/result copying | Forwarded shells plus jobs for cells, payloads, graph objects, paths and mutex views. Each root finishes before escaping. |
| Accounted value/type size | Array cursor and checked factor; nominal type queries use the iterative cache-free/cached path closed by Q-059. |
| Place projections, slice bytes | Flat index-path loops and byte loops. |
| Endpoint/atomic/mutex/buffer selectors | Their remaining self-calls follow at most one borrow on verified inputs: verifier operations require a direct handle or exactly a borrow of that handle. Resource/graph selectors already inspect one such place directly. |
| Task frames, channel roots, authorities | Explicit frame/root/parent loops; the existing call-depth limit is 1,024. |
| Race shadows, weak-memory views/messages | Flat entries/path copies and message loops. |
| Runtime JSON | Pending sequences inside one raw-value boundary; opaque handles are not traversed. |
The lifetime inspection finds a separate host-error defect: `run` releases its
execution arena only after successful result copying. A verified 1,024-byte
array program, through a private allocator seam retaining the old run body,
fails at result `Copier.ensureItems`; the controlled execution backing allocator
records 259,888 allocated bytes and zero freed bytes. These are host allocator
counters, not Aji authority charges. The failing unit assertion reproduces the
missing cleanup before the repair.
Execution-arena cleanup is now deferred on every run exit, still before output
and host cleanup and after complete returned-value copying/statistics on success.
The invariant is that returned payloads survive in the caller arena while all
execution-owned blocks are released on success or propagated host OOM. Collection
continues to discard its failed new arena; its successful replacement inherits
the same backing allocator. The private test seam exposes no public option or
semantic flag. The production allocator remains page-backed. There is no retry,
transactional collection or output rollback guarantee.
Verifier initialization/ownership/borrow rules, runtime safe points, Aji quota
charges, effects, traps, scheduling and fuel are unchanged. The existing
zero_structure_siblings and returned_mixed_json AIR/source pairs remain valid;
read_uninitialized/copy_overlapping still reject E1010/E2101. No new diagnostic
is added: OutOfMemory remains a host error and no partial Outcome is returned.
The public run API and successful records retain backward compatibility.
Failure tests cover every caller-arena and execution-backing request, including
result copying and fresh collection arenas, under ordinary and per-instruction
collection. All failed/completed heaps have equal allocated/freed counters;
successful arrays remain readable after heap release. Units, format checks,
test-extended and all 1,793 ordinary conformance cases pass with exact coverage.
Twenty-nine old/new deterministic/hosted CLI pairs retain exact records and
independently expected fuel boundaries/values at depths 0–32,768. The full
per-instruction runs and the focused std run remain live validation; Q-060 and
Phase 6 are not closed by these ordinary results. No fresh Claude review is claimed.