miri/const eval: support MaybeDangling#150446
miri/const eval: support MaybeDangling#150446WaffleLapkin wants to merge 1 commit intorust-lang:mainfrom
MaybeDangling#150446Conversation
This comment has been minimized.
This comment has been minimized.
96d2a1d to
72213c3
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
72213c3 to
0d9e008
Compare
This comment has been minimized.
This comment has been minimized.
0d9e008 to
ae69218
Compare
This comment has been minimized.
This comment has been minimized.
|
Does this have insta-stable behavior change for ManuallyDrop in consteval? |
|
It should only affect the behavior of code that still has UB until |
|
It is very import that we land #150447 before landing this, to avoid a situation where we generate LLVM IR with UB but Miri reports no UB. |
e5b7d00 to
959b31b
Compare
|
@RalfJung I think I've addressed the review comments and this is ready for review too :) (still blocked on the compiler change though) |
By "the compiler change" you mean #150447 ? |
|
yes |
This comment has been minimized.
This comment has been minimized.
959b31b to
ac559e4
Compare
This comment has been minimized.
This comment has been minimized.
ac559e4 to
d14294e
Compare
This comment has been minimized.
This comment has been minimized.
|
Please rebase so it's easier to see the diff. :) Also, CI doesn't seem entirely happy yet. |
|
Error: Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
|
(retry for debugging) @rustbot author |
|
(It was a 500 GitHub error) |
d14294e to
955b127
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| /// If this is `Some`, then `reset_provenance_and_padding` must be true (but not vice versa: | ||
| /// we might not track data vs padding bytes if the operand isn't stored in memory anyway). | ||
| data_bytes: Option<RangeSet>, | ||
| may_dangle: bool, |
There was a problem hiding this comment.
This isn't even a borrow checking thing. Please move the test to tests/fail/validity and have it disable Stacked Borrows to ensure we don't rely on the aliasing model for catching this.
| } | ||
| } | ||
| ty::Adt(adt, _) if adt.is_maybe_dangling() => { | ||
| let could_dangle = mem::replace(&mut self.may_dangle, true); |
There was a problem hiding this comment.
| let could_dangle = mem::replace(&mut self.may_dangle, true); | |
| let old_may_dangle = mem::replace(&mut self.may_dangle, true); |
| Ub(DanglingIntPointer { addr: 0, .. }) => NullPtr { ptr_kind, maybe: false }, | ||
| Ub(DanglingIntPointer { addr: i, .. }) => DanglingPtrNoProvenance { | ||
| ptr_kind, | ||
| // FIXME this says "null pointer" when null but we need translate |
There was a problem hiding this comment.
| // FIXME this says "null pointer" when null but we need translate |
While we're at it
There was a problem hiding this comment.
This comment doesn't make sense any more since we're skipping that part when may_dangle is true.
| // Make sure this is non-null. We checked dereferenceability above, but if `size` is zero | ||
| // that does not imply non-null. |
There was a problem hiding this comment.
| // Make sure this is non-null. We checked dereferenceability above, but if `size` is zero | |
| // that does not imply non-null. | |
| // Make sure this is non-null. This is obviously needed when `may_dangle` is set, | |
| // but even if we did check dereferenceability above that would still allow null | |
| // pointers if `size` is zero. |
src/tools/miri/tests/fail/unaligned_pointers/maybe_dangling_unalighed.rs
Show resolved
Hide resolved
There was a problem hiding this comment.
Given that this case was contentious, please also add a test like
// Under the current models, we do not forbid writing through
// `MaybeDangling<&i32>`. That's not yet finally decided, but meanwhile
// ensure we document this and notice when it changes.
fn write_through_shr(x: MaybeDangling<&i32>) {
let y: *mut i32 = transmute(x);
y.write(1);
}
let mutref = &mut 0i32;
write_through_shr(transmute(mutref));
This comment has been minimized.
This comment has been minimized.
c052e2f to
7b01b7c
Compare
7b01b7c to
4a26802
Compare
|
@RalfJung I think I addressed your nits, unless I missed something ^^' |
There was a problem hiding this comment.
I meant for this to just be a new test in the other file -- no reason to split it up.
| self.check_wide_ptr_meta(place.meta(), place.layout)?; | ||
| } | ||
| // Make sure this is dereferenceable and all. | ||
|
|
There was a problem hiding this comment.
| // Determine size and alignment of pointee. |
View all comments
r? RalfJung