-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 detects a violation of stacked borrows when joining &str with -Zmiri-tag-raw-pointers #91574
Comments
I think this is UB even in the absence of stacked borrows because this code tries to construct a slice of uninit T: Lines 180 to 181 in e6b883c
Therefore, I think the way to go is replacing this with |
Yeah, it technically is, but inside the standard library we sometimes exploit the fact that we know that currently, rustc does not actually make use of that particular UB. (And I personally think we should allow references to uninit data, unless the type is entirely uninhabited. But that is a discussion for rust-lang/unsafe-code-guidelines#77.) The aliasing issue seems more severe. |
…, r=dtolnay Use spare_capacity_mut instead of invalid unchecked indexing when joining str This is a fix for rust-lang#91574 I think in general I'd prefer to see this code implemented with raw pointers or `MaybeUninit::write_slice`, but there's existing code in here based on copying from slice to slice, so converting everything from `&[T]` to `&[MaybeUninit<T>]` is less disruptive.
…r=dtolnay Use spare_capacity_mut instead of invalid unchecked indexing when joining str This is a fix for rust-lang#91574 I think in general I'd prefer to see this code implemented with raw pointers or `MaybeUninit::write_slice`, but there's existing code in here based on copying from slice to slice, so converting everything from `&[T]` to `&[MaybeUninit<T>]` is less disruptive.
Closed by #91680 |
Originally found by @5225225, I'm just the one with energy at the moment to write this up.
I tried this code:
MIRIFLAGS="-Zmiri-tag-raw-pointers" cargo miri run
I expected to see this happen: Miri does not detect UB
Instead, this happened: Miri detects UB (experimentally)
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: