-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Miri: Skip over GlobalAllocs when sweeping #118080
Closed
Closed
Changes from all commits
Commits
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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -648,32 +648,27 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<' | |
}; | ||
|
||
let (_size, _align, alloc_kind) = this.get_alloc_info(alloc_id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not care about size and align so it should call |
||
match alloc_kind { | ||
AllocKind::LiveData => { | ||
// This should have alloc_extra data, but `get_alloc_extra` can still fail | ||
// if converting this alloc_id from a global to a local one | ||
// uncovers a non-supported `extern static`. | ||
let extra = this.get_alloc_extra(alloc_id)?; | ||
let mut stacked_borrows = extra | ||
.borrow_tracker_sb() | ||
.borrow_mut(); | ||
// Note that we create a *second* `DiagnosticCxBuilder` below for the actual retag. | ||
// FIXME: can this be done cleaner? | ||
let dcx = DiagnosticCxBuilder::retag( | ||
&this.machine, | ||
retag_info, | ||
new_tag, | ||
orig_tag, | ||
alloc_range(base_offset, size), | ||
); | ||
let mut dcx = dcx.build(&mut stacked_borrows.history, base_offset); | ||
dcx.log_creation(); | ||
if new_perm.protector().is_some() { | ||
dcx.log_protector(); | ||
} | ||
}, | ||
AllocKind::Function | AllocKind::VTable | AllocKind::Dead => { | ||
// No stacked borrows on these allocations. | ||
if alloc_kind.is_live_data() { | ||
// This should have alloc_extra data, but `get_alloc_extra` can still fail | ||
// if converting this alloc_id from a global to a local one | ||
// uncovers a non-supported `extern static`. | ||
let extra = this.get_alloc_extra(alloc_id)?; | ||
let mut stacked_borrows = extra | ||
.borrow_tracker_sb() | ||
.borrow_mut(); | ||
// Note that we create a *second* `DiagnosticCxBuilder` below for the actual retag. | ||
// FIXME: can this be done cleaner? | ||
let dcx = DiagnosticCxBuilder::retag( | ||
&this.machine, | ||
retag_info, | ||
new_tag, | ||
orig_tag, | ||
alloc_range(base_offset, size), | ||
); | ||
let mut dcx = dcx.build(&mut stacked_borrows.history, base_offset); | ||
dcx.log_creation(); | ||
if new_perm.protector().is_some() { | ||
dcx.log_protector(); | ||
} | ||
} | ||
Ok(()) | ||
|
@@ -1012,18 +1007,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { | |
// This is okay because accessing them is UB anyway, no need for any Stacked Borrows checks. | ||
// NOT using `get_alloc_extra_mut` since this might be a read-only allocation! | ||
let (_size, _align, kind) = this.get_alloc_info(alloc_id); | ||
match kind { | ||
AllocKind::LiveData => { | ||
// This should have alloc_extra data, but `get_alloc_extra` can still fail | ||
// if converting this alloc_id from a global to a local one | ||
// uncovers a non-supported `extern static`. | ||
let alloc_extra = this.get_alloc_extra(alloc_id)?; | ||
trace!("Stacked Borrows tag {tag:?} exposed in {alloc_id:?}"); | ||
alloc_extra.borrow_tracker_sb().borrow_mut().exposed_tags.insert(tag); | ||
} | ||
AllocKind::Function | AllocKind::VTable | AllocKind::Dead => { | ||
// No stacked borrows on these allocations. | ||
} | ||
if kind.is_live_data() { | ||
// This should have alloc_extra data, but `get_alloc_extra` can still fail | ||
// if converting this alloc_id from a global to a local one | ||
// uncovers a non-supported `extern static`. | ||
let alloc_extra = this.get_alloc_extra(alloc_id)?; | ||
trace!("Stacked Borrows tag {tag:?} exposed in {alloc_id:?}"); | ||
alloc_extra.borrow_tracker_sb().borrow_mut().exposed_tags.insert(tag); | ||
} | ||
Ok(()) | ||
} | ||
|
This file contains 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 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 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
Oops, something went wrong.
Oops, something went wrong.
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.
Note that these might be global. On their first read or write, globals get copied into the
alloc_map
, which is needed because we need to convert them from the global provenance type to that of Miri.So what even is your definition of "global"? "AllocId is in
tcx
" or "AllocId is not inmemory
"? Those two are not equivalent.