Skip to content

Conversation

@royAmmerschuber
Copy link
Contributor

Currently, if we do a protector release access we assume that any other subtree (including the main subtree) could be a child of the accessed node, meaning we conservatively don't update them based on the access.

This PR determines as accurately as possible (under the current model), which other subtrees could be children of the accessed tag.
This means we now accurately reflect:

  • the main subtree is never a child of the accessed tag
  • if the accessed tag doesn't have exposed children, then no other subtree is a child of it
  • a subtree can only be a child of the accessed tag, if there exists an exposed child of the accessed tag with a tag less than the root of the subtree

@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2025

Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two.
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Dec 16, 2025
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

Mostly comments about comments, as usual. :)

View changes since this review

global,
ChildrenVisitMode::VisitChildrenOfAccessed,
&diagnostics,
None, // min_exposed_child only matters for protector end access,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
None, // min_exposed_child only matters for protector end access,
/* min_exposed_child */ None, // only matters for protector end access,

Comment on lines 954 to 955
if let Some(min_exposed_child) = min_exposed_child
&& tag > min_exposed_child
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this condition check visit_children?

Comment on lines 946 to 947
// On a protector release access we skip the children of the accessed tag so that
// we can correctly return references from functions. However, if the tag has
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// On a protector release access we skip the children of the accessed tag so that
// we can correctly return references from functions. However, if the tag has
// On a protector release access we have to skip the children of the accessed tag.
// However, if the tag has


/// This is a variant of the test in `../protector-write-lazy.rs`, but with
/// wildcard references.
/// Checks that a protector release transitions a foreign reference on a reference,
Copy link
Member

Choose a reason for hiding this comment

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

What does "transitions a foreign reference on a reference" mean?

/// wildcard references.
/// Checks that a protector release transitions a foreign reference on a reference,
/// if we can determine that it's not a child of the released tag.
/// For this version we know the tag is not a child, because its wildcard root has
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// For this version we know the tag is not a child, because its wildcard root has
/// For this version we know the tag is not a child because its wildcard root has

// │ │
// ▼ ▼
// ┌───────────┐ ┌───────────┐
// │ arg4 │ │ ref6│
Copy link
Member

Choose a reason for hiding this comment

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

Does the horizontal alignment of ref6 mean anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref6 was created as a reference to the second element of the array. arg4 to the first element

Copy link
Member

Choose a reason for hiding this comment

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

Ah :) Maybe extend the vertical line upwards to make that more clear?

Comment on lines 912 to 915
/// * `min_exposed_child`: any subtree that could be a child of `access_source` must
/// have a root with a larger tag than this. If None then no other subtree can be
/// a child of `access_source`.
/// This only gets read if `visit_children==SkipChildrenOfAccessed`.
Copy link
Member

Choose a reason for hiding this comment

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

The comment doesn't match the name. What about something like this?

Suggested change
/// * `min_exposed_child`: any subtree that could be a child of `access_source` must
/// have a root with a larger tag than this. If None then no other subtree can be
/// a child of `access_source`.
/// This only gets read if `visit_children==SkipChildrenOfAccessed`.
/// * `min_exposed_child`: The tag of the smallest exposed (transitive) child of the accessed node.
/// This is useful with `visit_children == SkipChildrenOfAccessed`, where we need to skip children
/// of the accessed.

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Dec 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 18, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@royAmmerschuber
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Dec 21, 2025
@RalfJung
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Dec 22, 2025
@royAmmerschuber
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Dec 22, 2025
@RalfJung
Copy link
Member

This looks great, thanks! Please squash the commits. You can squash manually if there are multiple independent commits you want to preserve, or use ./miri squash (make sure to pick a suitable commit message). Then write @rustbot ready after you force-pushed the squashed PR.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: Waiting for the PR author to address review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants