miri/const eval: support MaybeDangling#150446
Conversation
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) |
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.
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.
4a26802 to
76a750a
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. |
|
@rustbot review |
|
Awesome, thanks a lot! |
…r=RalfJung miri/const eval: support `MaybeDangling` r? RalfJung
…r=RalfJung miri/const eval: support `MaybeDangling` r? RalfJung
…r=RalfJung miri/const eval: support `MaybeDangling` r? RalfJung
Rollup merge of #150446 - WaffleLapkin:miri-maybe-dangling, r=RalfJung miri/const eval: support `MaybeDangling` r? RalfJung
…uwer Rollup of 4 pull requests Successful merges: - rust-lang/rust#147834 (Always make tuple elements a coercion site) - rust-lang/rust#150446 (miri/const eval: support `MaybeDangling`) - rust-lang/rust#153053 (stop marking `deref_patterns` as an incomplete feature) - rust-lang/rust#153398 (fix ICE in `const_c_variadic` when passing ZSTs)
View all comments
r? RalfJung