Repository navigation
#690 Domain-bound allocation tracking for arenas and heap regions - #1351
Merged
Merged
Conversation
Memory bumped from a module-static arena or frame arena now carries that instance's declared @Lifetime(D). Storing it in a longer-lived static is an LD1 escape even when the writing function is unannotated. A parameter or local arena keeps the writer-domain rule; malloc is unchanged. The span-outlives fallback no longer treats a module-static arena name as function-local storage, so same-domain stores stay legal. Co-authored-by: Abhishek Shivakumar <[email protected]>
An unannotated function that stores arena_alloc of a parameter into a static is allowed (#690). Span-outlives now applies only to function-local storage. Also pin domain_arena fixture line numbers to the host checker. Co-authored-by: Abhishek Shivakumar <[email protected]>
Initializing module-static arena pointers from stack Arenas is itself an LD1/span escape. The accepted program now uses null statics and null-safe stubs so it only exercises legal same-or-shorter-lived stores. Co-authored-by: Abhishek Shivakumar <[email protected]>
The checked-in bootstrap C must stay byte-identical to flowc's bundle emit of compiler/src. Regenerated after the #690 type-checker change. Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht
marked this pull request as ready for review
October 5, 2026 11:59
…nerate bootstrap Conflicts: compiler/bootstrap (took main's, then bootstrap_from_c.sh --regen, fixed point at gen2 on macOS and Linux x86-64; the checked-in flowc_stage_a is rebuilt for Linux x86-64 like main's) and docs/project/CHANGELOG.md (kept main's entries and the #690 entry).
Only docs/project/CHANGELOG.md conflicted (after #1357); kept both.
Only compiler/bootstrap/flowc_stage_a conflicted (after #1350); took main's binary (C already matches).
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.
Intent
Linked issue or roadmap item: #690 (epic #679). Reference design: tag
archive/feat/690-arena-domains.What changed, and why is this the smallest useful change?
Pointers from
arena_alloc/frame_alloc_*of a module-static arena now carry that arena's declared@lifetime(D)(defaultapplication). Storing them in a longer-lived static is an LD1 domain escape even when the writing function is unannotated. A parameter or local arena keeps the existing writer-domain rule.mallocis unchanged. The span-outlives fallback no longer treats a module-static or parameter arena name as function-local storage, so same-domain stores stay legal.This is the Flow port of the retired-Python increment on that archive tag. Field-domain stores (
@lifetimeon a struct field) stay with #684.Overlap check
Overlap / dependency notes:
arena_allocresults to the arena argument name (writer-domain only).Evidence
Baseline before this change:
Checked-in
compiler/build/flowc_bootstrapondomain_arena_escape_unannotated.flowrejected the store asspan outlives borrowed storage \fa`and did not name the arena'sframedomain. Same-domain stores (applicationarena into anapplicationstatic) would also hit that span fallback.domain_arena_param_writer.flow` already produced the v0 writer-domain diagnostic.Targeted proof that exercises the changed behaviour:
compiler/fixtures/typecheck_rules/domain_arena_*.flow(escapes and legal cases) andtests/lang/test_arena_domains.flow. The unannotated frame-arena store now prints the LD1 message namingfa/frame/cache/application.Why that proof would detect the old failure or regression:
The old checker either accepted the store (no writer domain) or rejected it as a generic span-outlives of the arena name, including legal same-domain stores. The new fixtures require the domain-named diagnostic on escapes and
# expect: okon same-domain, unannotated-arena, malloc, and unannotated-parameter cases.Repository gate(s) run:
flowc: PASS./flow tool compiler/scripts/typecheck_rules.flow: 137 passed, 0 failed (host and regenerated bootstrap)./flow test-lang tests/lang/test_arena_domains.flow tests/lang/test_lifetime_domains.flow: both pass./compiler/scripts/bootstrap_from_c.sh --verify: ALL PASS./flow tool compiler/scripts/self_host_full.flow: ALL PASS (three generations, byte-identical)Generated/bootstrap state, if any:
compiler/bootstrap/flowc_stage_a.cregenerated to a fixed point in a separate commit after the source edits.Risk
Compatibility, performance, security, lifetime, backend, or release implications:
New hard errors on stores of shorter-lived module-static arena memory into longer-lived statics, including from unannotated functions. Same-domain stores that previously failed as
span outlives borrowed storagebecome legal. No codegen change; the annotation remains erased.docs/project/Questions.mdupdated if this needs a language-design decision.Compatibility
docs/project/CHANGELOG.md.Agent handoff
Agent/provider/session: Cursor cloud agent, branch
cursor/arena-domain-tracking-690-bb9d.Any remaining blocker is recorded in GitHub rather than only in local/session state:
Documented limits (same class as other lifetime-domain gaps, not half-checked): intra-function use after
arena_reset/frame_begin; escape through a#684field domain; value-typed struct module statics (useptr<Arena>).Closes #690