Skip to content
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

fix handling of spurious accesses during retag #2694

Merged
merged 4 commits into from
Nov 27, 2022

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Nov 26, 2022

The dereferenceable attribute we emit for LLVM is checked during retag in Stacked Borrows.
However, we currently don't properly do that for retagging of &mut !Unpin, which this PR fixes.
Also this adjusts retagging to inform the data race model of the accesses as well.

Fixes #2648.
Also fixes #2693 since the same issue arose for retagging as well.

r? @saethlin

@rustbot

This comment was marked as off-topic.

@RalfJung
Copy link
Member Author

While I was touching retagging anyway, I also added a fix for #2648.

let Operation::Dealloc(op) = &self.operation else {
unreachable!("dealloc_error should only be called during a deallocation")
};
err_sb_ub(
format!(
"no item granting write access for deallocation to tag {:?} at {:?} found in borrow stack",
op.tag, self.history.id,
"attemtping deallocation using {tag:?} at {alloc_id:?}{cause}",
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
"attemtping deallocation using {tag:?} at {alloc_id:?}{cause}",
"attempting deallocation using {tag:?} at {alloc_id:?}{cause}",

})?;
drop(global);
if let Some(access) = access {
assert!(access == AccessKind::Read);
Copy link
Member

Choose a reason for hiding this comment

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

If I recall correctly, assert_eq! produces better panic messages, so I always use it when possible

Copy link
Member Author

Choose a reason for hiding this comment

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

It prints what the values actually were. But here there are only two options.

But yeah probably better to get in the habit of using assert_eq.

@saethlin
Copy link
Member

saethlin commented Nov 26, 2022

I skimmed over this but I'm a bit fried right now, I'll look over it for real tomorrow. (some of the changes look like they are worth me understanding properly, and right now I do not)

@saethlin
Copy link
Member

I think I understand this decently well now. r=me whenever you want to merge (we have a number of outstanding PRs which may be disruptive so I'm not going to just send this)

@RalfJung
Copy link
Member Author

We'll have to land them in some order... 🤷
@bors r=saethlin

@bors
Copy link
Contributor

bors commented Nov 27, 2022

📌 Commit 776460f has been approved by saethlin

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Nov 27, 2022

⌛ Testing commit 776460f with merge 9f30f00...

@bors
Copy link
Contributor

bors commented Nov 27, 2022

☀️ Test successful - checks-actions
Approved by: saethlin
Pushing 9f30f00 to master...

@bors bors merged commit 9f30f00 into rust-lang:master Nov 27, 2022
@RalfJung RalfJung deleted the retag-deref-check branch November 27, 2022 20:41
bors added a commit that referenced this pull request Dec 3, 2022
for now, do not do fake reads on non-Unpin mutable references

Work-around for rust-lang/unsafe-code-guidelines#381, needed to make the new test pass. Undoes parts of #2694.
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Dec 5, 2022
for now, do not do fake reads on non-Unpin mutable references

Work-around for rust-lang/unsafe-code-guidelines#381, needed to make the new test pass. Undoes parts of rust-lang/miri#2694.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants