-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Miri engine: stronger type-based sanity check for assignments #70532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f1ea273
Miri engine: stronger type-based sanity check for assignments
RalfJung 100c809
also accept fn-ptr-type-changing assignments
RalfJung 351b7d0
also use mir_assign_valid_types in from_known_layout check
RalfJung 343b3f0
switch assignment check back to testing layout equality
RalfJung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there remaining
layout.layout
in miri? Since that was what we were looking at.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one:
rust/src/librustc_mir/interpret/operand.rs
Line 219 in 8045865
That is verifying that the given layout matches the one we would have computed, so I think here comparing layouts for equality actually makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like that's all "destination layout" type stuff? i.e. where you might have a layout from knowing where a value might be written?
I think it should be better named/described as such, and should also use a type check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the function is called
from_known_layout
and documented asThat seems pretty clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact I wonder why this does not just compare the types... let me try that (but it might have the same potential mismatches as assignments).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"existing layout" doesn't explain that it's a destination layout, whereas the one that might be computed or compared against is a source one.
If we end up doing subtyping checks, the direction matters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the callers here uniformly make one source and one destination.
The check we do here should be symmetric. And indeed the actual relation we care about is not subtyping, it is layout compatibility -- and that relation is symmetric. Subtyping is just an approximation of that (and it needs more properties, which makes it asymmetric).
I would find it highly suspicious if
mir_assign_valid_types
ended up being asymmetric.