Skip to content
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: unsupported operation with -Zmiri-strict-provenance #188

Closed
wcampbell0x2a opened this issue Jul 13, 2022 · 2 comments
Closed

Miri: unsupported operation with -Zmiri-strict-provenance #188

wcampbell0x2a opened this issue Jul 13, 2022 · 2 comments

Comments

@wcampbell0x2a
Copy link
Contributor

wcampbell0x2a commented Jul 13, 2022

Found within sharksforarms/deku#266, but first found in bitvec.

$ MIRIFLAGS="-Zmiri-strict-provenance" cargo miri test
test array::tests::format::render ... error: unsupported operation: integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`
   --> src/ptr/span.rs:254:5
    |
254 |                 (self.ptr.as_ptr() as usize & Self::PTR_ADDR_MASK) as *mut T,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 `ptr::span::BitSpan::<wyz::Const, u8>::address` at src/ptr/span.rs:254:5
note: inside `ptr::span::BitSpan::<wyz::Const, u8>::render::<std::option::Option<&(&str, &dyn std::fmt::Debug)>>` at src/ptr/span.rs:671:20
   --> src/ptr/span.rs:671:20
    |
671 |             .field("addr", &self.address().fmt_pointer())
    |                             ^^^^^^^^^^^^^^
note: inside `array::traits::<impl std::fmt::Debug for array::BitArray<u8>>::fmt` at src/array/traits.rs:255:3
   --> src/array/traits.rs:255:3
    |
255 |         self.as_bitspan().render(fmt, "Array", None)?;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: inside `std::fmt::write` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:1198:17
    = note: inside `<std::string::String as std::fmt::Write>::write_fmt` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:188:9
    = note: inside `std::fmt::format::format_inner` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/fmt.rs:612:9
    = note: inside closure at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/fmt.rs:616:34
    = note: inside `std::option::Option::<&str>::map_or_else::<std::string::String, [closure@std::fmt::format::{closure#0}], for<'r> fn(&'r str) -> <str as std::borrow::ToOwned>::Owned {<str as std::borrow::ToOwned>::to_owned}>` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:1023:21
    = note: inside `std::fmt::format` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/fmt.rs:616:5
note: inside `array::tests::format::render` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/macros.rs:116:19
   --> src/array/tests.rs:152:16
    |
152 |         let render = format!("{:?}", BitArray::<u8, Lsb0>::ZERO);
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure at src/array/tests.rs:151:2
   --> src/array/tests.rs:151:2
    |
150 |       #[test]
    |       ------- in this procedural macro expansion
151 | /     fn render() {
152 | |         let render = format!("{:?}", BitArray::<u8, Lsb0>::ZERO);
153 | |         assert!(render.starts_with(&format!(
154 | |             "BitArray<u8, {}>",
...   |
174 | |         );
175 | |     }
    | |_____^
    = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error

error: test failed, to rerun pass '--lib'

Not sure on bitvecs working with general miri, or if strict-provenance is a goal of this crate.

@myrrlyn
Copy link
Collaborator

myrrlyn commented Sep 4, 2022

Strict provenance is absolutely a goal. Please continue to report Miri violations.

@myrrlyn myrrlyn closed this as completed in 4e7f511 Sep 4, 2022
@marmeladema
Copy link

Hi!
I've just hit the same issue but I see it is fixed in the main branch.
@myrrlyn do you think a patch release could be issued for this?
crates.io says latest version is still 1.0.1

Thank you in advance :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants