Skip to content

#690 Domain-bound allocation tracking for arenas and heap regions - #1351

Merged
godofecht merged 8 commits into
mainfrom
cursor/arena-domain-tracking-690-bb9d
Oct 6, 2026
Merged

godofecht merged 8 commits into
mainfrom
cursor/arena-domain-tracking-690-bb9d

Conversation

@godofecht

@godofecht godofecht commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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) (default application). 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. malloc is 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 (@lifetime on a struct field) stay with #684.

Overlap check

  • I searched open pull requests and recent commits for overlapping work.
  • This does not duplicate another active implementation, or the relationship is explained below.

Overlap / dependency notes:

Evidence

Baseline before this change:

Checked-in compiler/build/flowc_bootstrap on domain_arena_escape_unannotated.flow rejected the store as span outlives borrowed storage \fa`and did not name the arena'sframe domain. 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) and tests/lang/test_arena_domains.flow. The unannotated frame-arena store now prints the LD1 message naming fa / 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: ok on same-domain, unannotated-arena, malloc, and unannotated-parameter cases.

Repository gate(s) run:

  • Host selftest: 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.c regenerated 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 storage become legal. No codegen change; the annotation remains erased.

  • No unresolved language/API design decision is being implemented implicitly.
  • No unrelated generated artifacts or local state are included.
  • Docs changed when user-visible behaviour or syntax changed.
  • docs/project/Questions.md updated if this needs a language-design decision.

Compatibility

  • No user-visible compatibility change.
  • Compatibility change is documented in 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 #684 field domain; value-typed struct module statics (use ptr<Arena>).

Closes #690

Open in Web Open in Cursor 

cursoragent and others added 4 commits October 5, 2026 11:47
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
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).
@godofecht
godofecht merged commit eb36c01 into main Oct 6, 2026
40 checks passed
godofecht added a commit that referenced this pull request Oct 6, 2026
Resolve CHANGELOG both-sides. Regenerate bootstrap C and Linux
flowc_stage_a ELF to match post-#1351 main.
@godofecht
godofecht deleted the cursor/arena-domain-tracking-690-bb9d branch October 12, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flow 2.0] Domain-bound allocation tracking for arenas and heap regions

2 participants