Repository navigation
Ownership: generator frames own what they hold; close-out leak fixes (ABI v17) - #104
Merged
Merged
Conversation
…turn value are released on destroy, finish and unwind Destroying a frame that is not finished re-enters its resume function at the suspended yield, runs the enclosing finally blocks and drops the locals OwnershipFlow has Own there; an exception leaving the body marks the generator finished and drops through cleanup pads. ABI v17. Fixes #22 Fixes #43 Fixes #44
…sk arenas, aggregate generator iterators, minted compare strings and closure aliases are released A foreach over a generator or an iterator binds its value at the loop's own class, so one variable rebound by two such loops no longer keeps a reference per iteration. Found by the close-out soak: a fiber context frees the arena it saved; the generator getIterator() hands an IteratorAggregate foreach is released at loop end; a string a cast mints as a compare operand against a cell is freed by every operator (array_key_exists with a string key); a closure aliased into a local of a monomorphized callable callee is owned. Remaining leak repros pinned as tests. Fixes #23
…nd the iterator the loop holds The iterator getIterator() hands a foreach lives in a hidden local OwnershipFlow owns, and the loop's own protocol calls (a generator resume, rewind / valid / current / key / next) carry the locals Own at the loop head, so an unwind through them runs the same cleanup as any call's. Fixes #103
blacktrs
added a commit
that referenced
this pull request
Oct 7, 2026
…114) * Remove the Zend cold seed; docs follow the pinned-release bootstrap The compiler bootstraps from BOOTSTRAP_VERSION (#112), so the seed has no consumer left. Removed: bin/compile, tools/compile_files_mir.php, bin/build --seed/--auto-seed, gate.sh MC_ZEND_SEED, install.sh's Zend fallback, and the dead tools composer_data_smoke.sh, typecheck_scan.sh, split_ll.php, docker/iopoll/diag.sh, docker/symfony_probe.sh. selfhost_stability.sh rebuilds through the manifest path instead of Zend; composer.json drops the php requirement (the installer downloads the release or builds from the pin). Docs: every guide, README and design note audited against the tree — seed instructions removed or marked historical, ABI references point at MemoryAbi::VERSION (18), memory-abi.md gains the 64-byte descriptor (json_fn), the v14 BIGINT box and the v18 native buffer block, pass tables gain NarrowScalarGuards, ResolveMethodFcc, ResolveOverloads, SpillFreshBases and OwnershipFlow. * docs/design: ownership flow, native buffers and stage0 bootstrap notes Three shipped designs had no design note: per-program-point ownership (OwnershipFlow, #15/#104), the native fixed-width buffer runtime behind SplFixedArray and Manticore\Ds (#108), and the pinned-release bootstrap (#112/#114). Each is derived from the code it cites; AGENTS.md links the stage0 note.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the ownership redesign (plan Tasks 10–11, follow-up to #15): a generator frame owns everything it holds, and the leaks the close-out soak surfaced are fixed. Memory ABI goes to v17.
Generators (Task 10)
finallyblocks around the yield first, then drops its locals — php's order.current()/key()answer null afterwards.send()no longer leaks and the slot is cleared once read; a yielded key object is released; the loop's key variable owns its key.next()on a finished generator no longer restarts the body.How: the frame is still freed through the string release;
__mir_str_reclaimnow calls__mir_gen_destroy, which re-enters the resume function at-2 - state. Each yield carries the exit of a generator abandoned there, with the drop set OwnershipFlow computes for an unwind from that point. Resume functions get the same cleanup pads as any function.Close-out (Task 11)
getIterator()hands aforeachover anIteratorAggregateis released when the loop ends, and an exception out of a loop's own iterator step drops the frame's locals and that iterator.array_key_exists()with a string key kept one buffer per call.callablecallee (Closure::fromCallable()) gives its reference back.stream_socket_get_name()declares itsstring|falsereturn.Evidence
ef9e3ac4: AOT suite 1671 passed / 0 failed; gen2 == gen3 IR identical.leaks --atExit(main: 7.4 MB at 3000).Not run:
tools/difftest.sh, the Linux gate,bench/. This touches the runtime, the fiber context and the ABI, so the Linux gate is required before merge.Known gaps (in
docs/ROADMAP.md)new Xwritten inline as aforeachsubject is not released when an exception leaves the loop.yieldreached in afinallywhile the generator is being destroyed suspends once more instead of raising php'sCannot yield from finally in a force-closed generator.strlen()of an int held in a cell crashes).Fixes #22
Fixes #23
Fixes #43
Fixes #44
Fixes #103