-
Notifications
You must be signed in to change notification settings - Fork 182
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
Yoke vs strong protection #3696
Comments
I was under the impression that the limited form of self-borrowing that Yoke does is sound, after comparing it with the soundness issues found in other self-borrow crates. I was also under the impression that the cited lifetime in code is not relevant for Stacked Borrows (which lets us use this lifetime to mean "runtime lifetime"). Have I misunderstood something? |
Is it sufficient to wrap the field in a |
Hm, no, that still causes the error |
|
So the lifetime itself isn’t relevant — the problem here is that SB now assumes that all passed-in references, no matter the lifetime, will be valid the entire function’s duration (LLVM’s
Specifically, you have to store |
The issue is that when Rust decides to pass a struct field-by-field, fields with reference type will get |
Afaik just |
Can confirm, I'll probably write an |
Not quite since |
Yes, this would drop on Drop, I don't need it to avoid the Drop AlmostMaybeDangling |
FWIW, the first version of
The idea is for it to act as a centralized placeholder until the RFC gets implemented and stabilized, much like with |
We try to be low dependency here unfortunately so I'd be reluctant to take that on but I'm really glad it exists!! |
@Manishearth would you prefer if we delay landing rust-lang/miri#2985 until you have a fix shipped? |
This just changes how complainy miri is, yes? (and does not change how likely it is the compiler will break things). If so I don't mind that landing and would probably prefer it land so next time I miri yoke I don't have to remember to add in flags 😄 yoke is currently miri-clean but icu4x is not due to zerovec (stacked borrows issues that we haven't been able to clean up until we bumped our MSRV, which was very recent) and some transitive deps like t1ha, so personally I do not mind if yoke becomes miri-unclean temporarily. We don't yet CI miri. @sffc to verify (the impact on our clients of the change suggested by ralf is that ICU4X will be more likely to error on the UB-checking tool miri when clients use our code, but we already error on that tool and there is not yet a strong community expectation for deps to be miri clean because miri and the rules it applies are still in flux. |
Yes. |
It seems fine to me if Miri adds more warnings, so long as it doesn't break the compilation of current Yoke / ICU4X versions. |
PR in #3735 if people want to take a look, the |
Fixed in #3735 |
The following code fails Miri when
-Zmiri-retag-fields
is enabled (which will become the default soon: rust-lang/miri#2985):Miri error message
Note that this is not the same as #2095. While #2095 deals with
noalias
, this deals with the different issue that the&'static [u8]
passed into the function is expected to be valid for as long as the function runs, but theVec
is deallocated while the function runs.See also:
The text was updated successfully, but these errors were encountered: