-
Notifications
You must be signed in to change notification settings - Fork 24
Fix attempted to read from stolen value
#27
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
Comments
For the record (context from #99):
|
Another code snippet that panics #[repr(u16)]
pub enum ProtocolVersion {
Mls10 = 1,
}
impl ProtocolVersion {
#[allow(non_upper_case_globals)]
fn tls_deserialize(bytes: &[u8]) -> core::result::Result<(Self, &[u8]), tls_codec::Error> {
const __TLS_CODEC_Mls10: u16 = ProtocolVersion::Mls10 as u16;
let (discriminant, remainder) =
<u16 as tls_codec::DeserializeBytes>::tls_deserialize(bytes)?;
match discriminant {
__TLS_CODEC_Mls10 => {
let result = ProtocolVersion::Mls10 {};
Ok((result, remainder))
}
_ => Err(tls_codec::Error::UnknownValue(discriminant.into())),
}
}
} |
139: Fix steal bug r=W95Psp a=W95Psp This is an attempt at fixing the frontend exporter bug described in #27. The fix is really simple: it's all about processing `const`-like items first. `@franziskuskiefer:` I tested a bit this fix on a reduced version of the example you posted in #27, but I think you've been hitting that much more, can you try this patch? EDIT: also tried on `@geonnave's` example of #27, seems to be fine as well! Co-authored-by: Lucas Franceschino <lucas.franceschino@inria.fr>
Another stealing bug (from issue #474): Originally posted by @franziskuskiefer in #474 (comment) Open this code snippet in the playground Status: works OK in |
It looks like the two examples here are not triggering the stealing bug anymore. |
My current understanding of stealing insofar as it affects us:
Hence even translating a type may steal a THIR/MIR body. |
Yes, exactly, that's what is happening :( |
If we could detect whether a value is already stolen, we could fallback to the optimized MIR/evaluated value for constants. |
Opened rust-lang/rust#128815 |
reproducer for a stealing bug with (I haven't shown you the playground yet @Nadrieril, right? 😃 'right click > show MIR' on a rust subexpression might be interesting to you :D) |
You should now be able to fix all MIR stealing bugs by using the |
This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days. |
I can't reproduce with any of the examples in here. Unless we have a reproducer, let's close this and open something new when we hit it again. |
We were discussing that yesterday with @Nadrieril: he found a way to override queries, which basically means we can just reimplement the code that used to do the stealing! 🥳 But indeed, on the THIR side of things, same thing for me, no stealing for a long time! |
This is still an issue (see linked libcrux issue above). |
You could solve these issues for good by overriding queries to catch the THIR directly after it is built. See here an example in Creusot that reliably catches the mir_built in this way. |
This fix still needs to be upstreamed to hax from hax-evit, so maybe keep this open? |
Out of curiosity, how did you fix it? |
Uh oh!
There was an error while loading. Please reload this page.
The frontend browses items of a crate in an order that causes this bug.
Some data in the Rust compiler is kept in a
Steal
, which is basically a box whose content can be stolen, that is pulled out of the memory (rustc uses arenas)Thus, the order in which we browse the crate to export every item matters: sometimes I inspect things that happens to be stolen before because of some previous inspections.
This is particularly true for constants, it seems.
Status: mostly fixed
attempted to read from stolen value
#27 (comment)) is fixedattempted to read from stolen value
#27 (comment)) is fixedHowever, I tried Hax on
core
, and I get new stolen stuff. Thus, there exists some scenarios in which this still fails.The text was updated successfully, but these errors were encountered: