Skip to content

Support recursive raw pointer types - #1609

Merged
sbillig merged 2 commits into
masterfrom
recursive-raw-pointees
Sep 28, 2026
Merged

sbillig merged 2 commits into
masterfrom
recursive-raw-pointees

Conversation

@sbillig

@sbillig sbillig commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Recursive raw-pointer types such as struct Node { value: u256, next: *Node } pass type checking but could not be lowered: computing the runtime class recursed through the pointee (runtime_stored_class query cycle). The borrow checker also did not terminate on ordinary programs over such types: repeated calls to joining or looping helpers, matching Option<*T> or enum payloads, and passing recursive enum payloads. Both reproduce on 1b296f748.

Runtime (967268e)

  • RawAddr holds an interned RawPointeeId instead of a resolved class. RawPointeeKey::Stored(TyId) is resolved lazily by resolve_stored_raw_pointee (canonical scope: first ADT scope in the type, empty assumptions). Scalar pointees are Exact.
  • Runtime class equivalence checks identity, then resolved-class equality, then a bounded worklist bisimulation (runtime/relation.rs).
  • Boundary matching retargets accepted raw arguments at BorrowLike and ExactShape(Ref(C)) to RawAddr(S, Exact(C)).
  • The explicit_raw_boundaries and pointer_first_class Sonatina snapshots change only in symbol hash suffixes and function order.

Borrow checker (7645481)

  • Summaries published an input poststate whenever a cell's contents differed from entry. That included changes from control-flow constraints and moves, and callers replayed these poststates as physical stores. With recursive inputs, a read-only call made reachable caller cells arbitrary, and each call multiplied conditional sources.
  • Moves retire capabilities with BorrowState::move_out and do not clobber overlapping cells. Callee consumption propagates to callers through ResolvedAvailability::consumed.
  • Input poststates are published only for cells that are written, freshly allocated, or overlapped by byte writes.
  • Arbitrary seeds, and replacements inside arbitrary memory, collapse into one ExternalOrigin::OpaqueMemory family per referent contract. Allocation and input cells keep their identities.
  • Reachability compares regions with existential witnesses renumbered, and a reachable traversal expands each region once.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T22:37:20.808892Z 24eb688 New commits
🔒 Security Review ✅ Completed 2026-09-27T22:38:19.585634Z 24eb688 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

A raw address embedded its complete target class, so classifying
`Node { next: *Node }` needed Node's layout while building it and cycled.
Name raw targets by an interned handle instead: a source recipe keyed by
the normalized target type, resolved only on dereference, or an exact
class for addresses taken from places, synthetic code, and specialized
boundaries. Scalar targets are classified directly.

Resolve source recipes in a context derived from the type (its first ADT
scope, empty assumptions) so one type has one handle in every function.
Compare differently spelled targets structurally where an operation needs
typed agreement, and retarget raw arguments accepted by borrow and
reference-shape boundaries to the boundary's exact pointee so both
spellings select the same runtime instance. Verification and naming stop
at deferred targets.
Summaries replayed non-writing changes to caller cells as physical stores,
which broke the frame property for read-only callees and multiplied
conditional sources across calls until the solver stalled on recursive
raw-pointer structures.

- Retire moved capabilities with `BorrowState::move_out` instead of an
  empty clobbering write, and propagate callee consumption to callers.
- Publish input poststates only for written, fresh, or byte-overlapped
  cells.
- Collapse arbitrary seeds and replacements inside arbitrary memory into
  one finite `OpaqueMemory` family per referent contract.
- Normalize existential witnesses in reachability and expand each
  region once per reachable traversal.
@sbillig
sbillig force-pushed the recursive-raw-pointees branch from 7645481 to 24eb688 Compare September 27, 2026 22:26
@sbillig
sbillig merged commit 6fa1ad7 into master Sep 28, 2026
9 checks passed
@sbillig
sbillig deleted the recursive-raw-pointees branch September 28, 2026 04:38
cburgdorf added a commit that referenced this pull request Sep 30, 2026
Several user-facing changes merged after 26.3 were missing release notes
entries:

- Bugfixes: event ABI `anonymous` flag (#1562), string literal escapes
  (#1563), effect provider identity (#1564), shared calls on non-Copy
  fields (#1581), recursive raw pointer types (#1609).
- Performance: `DynArray::get` for static elements (#1559), constant
  string ABI encoding (#1560), compile-time caching (#1617, #1619, #1621).
- Native backend features: workspaces, native tests and `std::io`
  (#1565), process arguments and CPU timing (#1566), `ByteBuffer`
  (#1580).
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.

1 participant