Skip to content

Intern-pool text views held across interning: an audit for the shape #1323

Closed

Description

@ehartford

From PR #1322. InternPool.resolve / Sema.pool_resolve return &str — a view into symbol_texts: Vec[str]. A binding of that view is dangling as soon as anything interns a new symbol (the table grows and the old buffer is freed). The derive generators did exactly that and the release compiler segfaulted on test/behavior/derive_enum_debug_clone.w (lldb: ldp x8, x9, [x20] on the freed type_name view in Sema.ct_generate_debug_derive). Only the current compiler generation exposes it: the pinned seed lowers such a let as a header copy, the current one as a true D27 view — so a stage1 built by the seed is blind to the class.

#1322 owns the 17 bindings in src/ComptimeTransform.w. The same shape appears elsewhere (counts of let x = self.pool_resolve[_symbol](sym) / intern.resolve(sym) at the end of a line): SemaCheck.w 70, Sema.w 24, SemaDecl.w 18, SemaDiag.w 3, CodegenDispatch.w 28, Codegen.w 25, CodegenTraits.w 16, Parser.w 9, Lsp.w 3. Most never intern before their last use, but nothing verifies that, and a blind .clone() sweep is the wrong fix (allocation on every hot path).

Wanted: a check that flags a pool-text view live across a call that can intern (with analyze fact over the live MIR call graph: view binding from resolve* whose scope contains a path:call to intern_str), so the remaining sites are classified by evidence and only the real ones are owned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions