-
Notifications
You must be signed in to change notification settings - Fork 110
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
Update rust-toolchain to nightly of 2023-07-30 #481
Conversation
This version and the time to update is chosen somewhat arbitrarily, as libtock-rs fails to build elf2tab on its current Rust toolchain (2022-06-10).
Okay, I think I hit a roadblock. After the update, Miri fails with the following:
Having read the linked strict provenance APIs documentation, I can understand why this is an error. However, I don't really know how to work around it. As far as I see it, we're using the The root cause of the issues we're facing here is that we can't create a raw pointer type from a "tagless" From what I understand, Miri doesn't leave us with too many options here, assuming we want to stick to using strict provenance checks:
I'll prototype the second approach for now, and will see whether I can work around the Miri issues this way. |
My "fix" seems to work, but it does prevent compilation on stable Rust. As far as I know, the only way to have this work on both stable (for compiling) and unstable (for testing with Miri) is to use conditional compilation. If we need to use conditional compilation anyways, it might make sense to go with the |
This updates `libtock-rs` to a relatively old Rust toolchain, which happens to ship a rustc v1.64.0-nightly such that the latest `elf2tab` release can build with it (v0.11.0). However, it's not too recent for Miri to complain about unsupported integer-to-pointer casts in strict-provenance mode: running 5 tests test tests::driver_check ... error: unsupported operation: integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance` --> /home/leons/dev/libtock-rs/platform/src/register.rs:25:18 | 25 | Register(value as *mut ()) | ^^^^^^^^^^^^^^^^ integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance` | = help: use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead = note: backtrace: = note: inside `<libtock_platform::Register as core::convert::From<u32>>::from` at /home/leons/dev/libtock-rs/platform/src/register.rs:25:18 = note: inside `<u32 as core::convert::Into<libtock_platform::Register>>::into` at /home/leons/.rustup/toolchains/nightly-2022-08-02-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:550:9 This serves as a bridge-update to get CI running again, until a proper fix for the above Miri error is integrated (see [1]). [1]: tock#481
I wouldn't rule out the possibility of this code running on a platform where I think the most standard/idiomatic fix here is to use If you really want to avoid adding another dependency, you could try copying the implementation from // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
// We use transmute rather than a cast so tools like Miri can tell that this
// is *not* the same as from_exposed_addr.
// SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that
// pointer).
#[cfg(miri)]
return unsafe { core::mem::transmute(addr) }; Note: we don't need conditional compilation here because we don't need However, I'm not 100% sure that'll work, because it's possible that Miri special-cases the |
I'm preparing a toolchain update PR that will supercede #481. I'd prefer to avoid sending a large PR that mixes these style updates with important `unsafe` code, so I'm splitting the update into two PRs.
This version and the time to update is chosen somewhat arbitrarily, as libtock-rs fails to build elf2tab on its current Rust toolchain (2022-06-10).