Skip to content

fix(rustlantis): invalidate nested pointer edges on uninit - #1159

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:fix/rustlantis-transitive-uninit-refs
Aug 28, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:fix/rustlantis-transitive-uninit-refs

Conversation

@uurl

@uurl uurl commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1158

Summary

Make PlaceGraph::mark_place_uninit remove outgoing Deref edges from pointer/reference values contained transitively in the place being marked uninitialized.

Previously, mark_place_uninit only removed the edge when the root place itself was a pointer, leaving stale graph edges for pointers nested inside aggregates.

Implementation

The change performs a structural traversal over the place and its subfields before marking the underlying storage uninitialized.

For each pointer/reference node encountered, its outgoing Deref edge is removed.

This traversal is intentionally separate from the existing memory invalidation traversal. The latter stops at nodes backed by a RunPointer, which is correct for clearing bytes but would otherwise prevent discovery of nested pointer nodes.

Incoming Deref edges are not removed. References outside the value that point into its storage therefore retain their graph relationship.

Tests

Added a regression test covering an aggregate containing nested:

  • shared references
  • raw pointers
  • an external reference pointing to the aggregate

The test verifies that:

  • nested outgoing Deref edges are removed after mark_place_uninit
  • the aggregate becomes uninitialized
  • the external incoming reference is preserved

Validation

From crates/fuzzer/rustlantis:

cargo fmt --all -- --check                         PASS
cargo test -p generate \
    uninit_removes_nested_deref_edges_but_preserves_incoming_refs
                                                     PASS
cargo test -p generate                             PASS (18/18)
cargo test --workspace                             PASS

From the repository root:

git diff --check                                   PASS

@uurl uurl changed the title fix(rustlantis): invalidate nested references on uninit rustlantis: invalidate nested pointer edges on uninit Aug 23, 2026
@uurl uurl changed the title rustlantis: invalidate nested pointer edges on uninit fix(rustlantis): invalidate nested pointer edges on uninit Aug 23, 2026
@nihalpasham nihalpasham added on-hold Paused: valid but deferred until a prerequisite decision or dependency resolves fuzzer Fuzzing infrastructure (rustlantis, difftest) labels Aug 24, 2026
@nihalpasham

nihalpasham commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is not blocked by a dependency or by the pointer-contract refactor; it remains open for normal correctness review.

  • The added regression already covers nested shared-reference and raw-pointer edges and preserves an external incoming-reference control.
  • We still need to reproduce that test failing on the base and passing on this head, then exercise array, enum, and move cases around the same traversal boundary.
  • Fuzz/Miri coverage and exact-head workspace, lint, and hosted checks remain outstanding.

Those regression, negative, and control checks follow the Discord acceptance criteria.

@nihalpasham nihalpasham added bug Something isn't working and removed on-hold Paused: valid but deferred until a prerequisite decision or dependency resolves labels Aug 24, 2026
@nihalpasham

nihalpasham commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Fix verified sound:

  • mark_place_uninit now walks structural subfields and cuts each nested pointer's outgoing Deref edge
  • it sits at the one choke point all uninit paths use (Deinit, moves, intrinsic re-init)
  • keeping incoming edges matches the rustlantis: make uninit reference invalidation transitive #1158 spec
  • the shift is strictly toward soundness: stale edges made dead pointers look live

One test gap, which I closed at landing: the tuple-only test can't tell this fix from the plausible wrong one (cutting edges inside the run-pointer-bounded walk), because tuples have no RunPointer:

(&x, *mut y)        tuple: both fixes pass
[*mut x, *mut y]    array: run sits on the array node,
                    only the subfield walk reaches the elements

I added the array case, an enum-variant pointer case, a mark_place_moved case, and recorded the fail-on-base run. Labels already right.

…r invalidation

The PR's tuple test passes even if the Deref-edge removal is folded into
the RunPointer-bounded update walk, because tuples get no RunPointer of
their own. An array of pointers is the distinguishing case: the array
node owns the RunPointer and the memory-bounded walk stops there, so
only the structural subfield walk reaches the pointer elements.

Add three tests next to the existing one:
- an [*const i32; 2] place whose elements must lose their outgoing
  Deref edges on uninit while an external incoming reference to the
  array survives;
- an enum whose active variant holds a pointer field, which must lose
  its Deref edge when the enum place is marked uninit;
- a mark_place_moved integration case proving a move of a tuple with a
  nested pointer invalidates the nested Deref edge end to end.

Signed-off-by: nihalpasham <[email protected]>

@nihalpasham nihalpasham left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix plus the added adversarial tests verified, fail-on-base recorded; CI green. Merging.

@nihalpasham
nihalpasham merged commit f23638e into NVIDIA:main Aug 28, 2026
51 checks passed
@uurl
uurl deleted the fix/rustlantis-transitive-uninit-refs branch August 31, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fuzzer Fuzzing infrastructure (rustlantis, difftest)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustlantis: make uninit reference invalidation transitive

2 participants