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 #266

Open
wcampbell0x2a opened this issue Jun 20, 2022 · 6 comments
Open

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

wcampbell0x2a opened this issue Jun 20, 2022 · 6 comments
Labels

Comments

@wcampbell0x2a
Copy link
Collaborator

Found this while adding miri to testing my adsb-deku crate. Which looked to be a deku issue.

I ran the same command within bitvec and none of its tests resulted in the undefined behavior. But that is v1.0.0, which deku still doesn't use :(

> cd deku
> MIRIFLAGS="-Zmiri-strict-provenance" cargo miri test
running 128 tests
test impls::bool::tests::test_bool::case_1 ... error: Undefined Behavior: pointer arithmetic failed: 0x4f28a7 is not a valid pointer
   --> /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mut_ptr.rs:469:18
    |
469 |         unsafe { intrinsics::offset(self, count) as *mut T }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer arithmetic failed: 0x4f28a7 is not a valid pointer
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

    = note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mut_ptr.rs:469:18
    = note: inside `bitvec::ptr::Address::<bitvec::ptr::Const, u8>::offset` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/wyz-0.4.0/src/comu.rs:207:16
    = note: inside `bitvec::prelude::BitPtr::<bitvec::ptr::Const, bitvec::order::Msb0, u8>::offset` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/ptr/single.rs:483:13
    = note: inside `bitvec::prelude::BitPtr::<bitvec::ptr::Const, bitvec::order::Msb0, u8>::add` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/ptr/single.rs:651:3
    = note: inside closure at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/slice/api.rs:2653:3
    = note: inside `<std::ops::RangeFrom<usize> as bitvec::slice::BitSliceIndex<bitvec::order::Msb0, u8>>::get_unchecked` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/slice/api.rs:2604:5
    = note: inside `bitvec::slice::api::<impl bitvec::prelude::BitSlice<bitvec::order::Msb0, u8>>::get_unchecked::<std::ops::RangeFrom<usize>>` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/slice/api.rs:470:3
    = note: inside `bitvec::prelude::BitSlice::<bitvec::order::Msb0, u8>::split_at_unchecked` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/slice.rs:1986:32
    = note: inside `bitvec::slice::api::<impl bitvec::prelude::BitSlice<bitvec::order::Msb0, u8>>::split_at` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/slice/api.rs:1194:12
note: inside `impls::primitive::<impl DekuRead<(ctx::Endian, ctx::Size)> for u8>::read` at src/impls/primitive.rs:31:41
   --> src/impls/primitive.rs:31:41
    |
31  |                 let (bit_slice, rest) = input.split_at(bit_size);
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^
...
263 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::primitive::<impl DekuRead<ctx::Endian> for u8>::read` at src/impls/primitive.rs:130:17
   --> src/impls/primitive.rs:130:17
    |
130 |                 <$typ>::read(input, (endian, max_type_bits))
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
263 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::primitive::<impl DekuRead for u8>::read` at src/impls/primitive.rs:151:17
   --> src/impls/primitive.rs:151:17
    |
151 |                 <$typ>::read(input, Endian::default())
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
263 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::bool::<impl DekuRead for bool>::read` at src/impls/bool.rs:18:27
   --> src/impls/bool.rs:18:27
    |
18  |         let (rest, val) = u8::read(input, inner_ctx)?;
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool` at src/impls/bool.rs:61:32
   --> src/impls/bool.rs:61:32
    |
61  |         let (rest, res_read) = bool::read(bit_slice, ()).unwrap();
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool::case_1` at src/impls/bool.rs:52:5
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
note: inside closure at src/impls/bool.rs:52:5
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
    = note: this error originates in the macro `ImplDekuRead` (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'
@wcampbell0x2a
Copy link
Collaborator Author

Annnd it's on our end, tested: #246.

test impls::bool::tests::test_bool::case_1 ... error: Undefined Behavior: pointer arithmetic failed: 0x4d39df is not a valid pointer
   --> /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mut_ptr.rs:469:18
    |
469 |         unsafe { intrinsics::offset(self, count) as *mut T }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer arithmetic failed: 0x4d39df is not a valid pointer
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

    = note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mut_ptr.rs:469:18
    = note: inside closure at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/wyz-0.5.0/src/comu.rs:259:24
    = note: inside `<*mut u8 as tap::pipe::Pipe>::pipe::<*mut u8, [closure@wyz::comu::Address<bitvec::ptr::Const, u8>::offset::{closure#0}]>` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/tap-1.0.1/src/pipe.rs:78:3
    = note: inside `wyz::comu::Address::<bitvec::ptr::Const, u8>::with_ptr::<u8, [closure@wyz::comu::Address<bitvec::ptr::Const, u8>::offset::{closure#0}]>` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/wyz-0.5.0/src/comu.rs:329:3
    = note: inside `wyz::comu::Address::<bitvec::ptr::Const, u8>::offset` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/wyz-0.5.0/src/comu.rs:259:4
    = note: inside `bitvec::ptr::BitPtr::<bitvec::ptr::Const, u8, bitvec::order::Msb0>::offset` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.0/src/ptr/single.rs:527:23
    = note: inside `bitvec::ptr::BitPtr::<bitvec::ptr::Const, u8, bitvec::order::Msb0>::add` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.0/src/ptr/single.rs:684:3
    = note: inside `bitvec::slice::BitSlice::<u8, bitvec::order::Msb0>::split_at_unchecked` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.0/src/slice.rs:857:15
    = note: inside `bitvec::slice::api::<impl bitvec::slice::BitSlice<u8, bitvec::order::Msb0>>::split_at` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.0/src/slice/api.rs:1154:12
note: inside `impls::primitive::<impl DekuRead<(ctx::Endian, ctx::Size)> for u8>::read` at src/impls/primitive.rs:31:41
   --> src/impls/primitive.rs:31:41
    |
31  |                 let (bit_slice, rest) = input.split_at(bit_size);
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^
...
211 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::primitive::<impl DekuRead<ctx::Endian> for u8>::read` at src/impls/primitive.rs:106:17
   --> src/impls/primitive.rs:106:17
    |
106 |                 <$typ>::read(input, (endian, max_type_bits))
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
211 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::primitive::<impl DekuRead for u8>::read` at src/impls/primitive.rs:127:17
   --> src/impls/primitive.rs:127:17
    |
127 |                 <$typ>::read(input, Endian::default())
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
211 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::bool::<impl DekuRead for bool>::read` at src/impls/bool.rs:18:27
   --> src/impls/bool.rs:18:27
    |
18  |         let (rest, val) = u8::read(input, inner_ctx)?;
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool` at src/impls/bool.rs:61:32
   --> src/impls/bool.rs:61:32
    |
61  |         let (rest, res_read) = bool::read(bit_slice, ()).unwrap();
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool::case_1` at src/impls/bool.rs:52:5
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
note: inside closure at src/impls/bool.rs:52:5
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
    = note: this error originates in the macro `ImplDekuTraits` (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'

@sharksforarms sharksforarms added the bug Something isn't working label Jul 4, 2022
@wcampbell0x2a wcampbell0x2a changed the title Miri: Undefined Behavior Miri: Undefined Behavior with -Zmiri-strict-provenance Jul 13, 2022
@wcampbell0x2a wcampbell0x2a changed the title Miri: Undefined Behavior with -Zmiri-strict-provenance Miri: unsupported operation with -Zmiri-strict-provenance Jul 13, 2022
@wcampbell0x2a
Copy link
Collaborator Author

This message has been changed on nightly:

test impls::bool::tests::test_bool::case_1 ... error: unsupported operation: integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`
   --> /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/ptr/span.rs:343:32
    |
343 |             ptr: NonNull::new_unchecked((ptr_data | ptr_head) 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 `bitvec::ptr::span::BitSpan::<bitvec::ptr::Const, bitvec::order::Msb0, u8>::new_unchecked` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/ptr/span.rs:343:32
    = note: inside `bitvec::prelude::BitPtr::<bitvec::ptr::Const, bitvec::order::Msb0, u8>::span_unchecked` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/ptr/single.rs:267:3
    = note: inside `bitvec::prelude::BitSlice::<bitvec::order::Msb0, u8>::from_slice_unchecked` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/slice.rs:703:3
    = note: inside `bitvec::prelude::BitSlice::<bitvec::order::Msb0, u8>::from_slice` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/slice.rs:615:15
    = note: inside `<[u8] as bitvec::view::BitView>::view_bits::<bitvec::order::Msb0>` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.22.3/src/view.rs:124:3
note: inside `impls::bool::tests::test_bool` at src/impls/bool.rs:60:25
   --> src/impls/bool.rs:60:25
    |
60  |         let bit_slice = input.view_bits::<Msb0>();
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool::case_1` at src/impls/bool.rs:52:5
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
note: inside closure at src/impls/bool.rs:52:5
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
    = note: this error originates in the attribute macro `rstest` (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'

looks like more of a bitvec problem.

from the update to v1.0.1 branch:

test impls::bool::tests::test_bool::case_1 ... error: unsupported operation: integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`
   --> /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.1/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 `bitvec::ptr::span::BitSpan::<bitvec::ptr::Const, u8, bitvec::order::Msb0>::address` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.1/src/ptr/span.rs:254:5
    = note: inside `bitvec::ptr::span::BitSpan::<bitvec::ptr::Const, u8, bitvec::order::Msb0>::to_bitptr` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.1/src/ptr/span.rs:533:34
    = note: inside `bitvec::slice::BitSlice::<u8, bitvec::order::Msb0>::as_bitptr` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.1/src/slice.rs:450:3
    = note: inside `bitvec::slice::BitSlice::<u8, bitvec::order::Msb0>::split_at_unchecked` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.1/src/slice.rs:879:14
    = note: inside `bitvec::slice::api::<impl bitvec::slice::BitSlice<u8, bitvec::order::Msb0>>::split_at` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-1.0.1/src/slice/api.rs:1190:12
note: inside `impls::primitive::<impl DekuRead<(ctx::Endian, ctx::Size)> for u8>::read` at src/impls/primitive.rs:31:41
   --> src/impls/primitive.rs:31:41
    |
31  |                 let (bit_slice, rest) = input.split_at(bit_size);
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^
...
211 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::primitive::<impl DekuRead<ctx::Endian> for u8>::read` at src/impls/primitive.rs:106:17
   --> src/impls/primitive.rs:106:17
    |
106 |                 <$typ>::read(input, (endian, max_type_bits))
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
211 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::primitive::<impl DekuRead for u8>::read` at src/impls/primitive.rs:127:17
   --> src/impls/primitive.rs:127:17
    |
127 |                 <$typ>::read(input, Endian::default())
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
211 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::bool::<impl DekuRead for bool>::read` at src/impls/bool.rs:18:27
   --> src/impls/bool.rs:18:27
    |
18  |         let (rest, val) = u8::read(input, inner_ctx)?;
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool` at src/impls/bool.rs:61:32
   --> src/impls/bool.rs:61:32
    |
61  |         let (rest, res_read) = bool::read(bit_slice, ()).unwrap();
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool::case_1` at src/impls/bool.rs:52:5
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
note: inside closure at src/impls/bool.rs:52:5
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
    = note: this error originates in the macro `ImplDekuTraits` (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`

@wcampbell0x2a
Copy link
Collaborator Author

This might be fixed, but not published. ferrilab/bitvec@4e7f511

@sharksforarms
Copy link
Owner

Thanks for staying on top of this @wcampbell0x2a! This would be pending #246 most likely

@wcampbell0x2a
Copy link
Collaborator Author

Well, the fix for the above problem isn't in bitvec v1.0.1, and that fix is on github but not on crates.io for v1.1.0.

Updating to taking bitvec from the git repo give me a new error!

Miri Output
MIRIFLAGS="-Zmiri-strict-provenance" cargo miri test
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
   Compiling bitvec v1.1.0 (https://github.com/ferrilab/bitvec.git?branch=main#96baa439)
   Compiling deku v0.15.1 (/home/wcampbell/projects/wcampbell/deku)
    Finished test [unoptimized + debuginfo] target(s) in 2.29s
     Running unittests src/lib.rs (target/miri/x86_64-unknown-linux-gnu/debug/deps/deku-1e68a843a6e0d7a7)

running 128 tests
test impls::bool::tests::test_bool::case_1 ... error: Undefined Behavior: trying to retag from <249035> for SharedReadOnly permission at alloc97824[0x0], but that tag does not exist in the borrow stack for this location
   --> /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/raw.rs:100:9
    |
100 |         &*ptr::slice_from_raw_parts(data, len)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |         |
    |         trying to retag from <249035> for SharedReadOnly permission at alloc97824[0x0], but that tag does not exist in the borrow stack for this location
    |         this error occurs as part of retag at alloc97824[0x0..0x1]
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <249035> would have been created here, but this is a zero-size retag ([0x0..0x0]) so the tag in question does not exist anywhere
   --> src/impls/primitive.rs:35:16
    |
35  |             && bit_slice.domain().region().unwrap().1.len() * 8 == MAX_TYPE_BITS
    |                ^^^^^^^^^^^^^^^^^^
    = note: BACKTRACE (of the first span):
    = note: inside `std::slice::from_raw_parts::<'_, u8>` at /home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/raw.rs:100:9: 100:47
    = note: inside `<wyz::comu::Address<bitvec::ptr::Const, [u8]> as wyz::comu::SliceReferential<'_>>::from_raw_parts` at /home/wcampbell/.cargo/registry/src/github.com-1ecc6299db9ec823/wyz-0.5.1/src/comu.rs:589:3: 589:45
    = note: inside `bitvec::domain::Domain::<'_, bitvec::ptr::Const, u8, bitvec::order::Msb0>::spanning` at /home/wcampbell/.cargo/git/checkouts/bitvec-57b76272ba94d770/96baa43/src/domain.rs:501:5: 504:6
    = note: inside `bitvec::domain::Domain::<'_, bitvec::ptr::Const, u8, bitvec::order::Msb0>::new` at /home/wcampbell/.cargo/git/checkouts/bitvec-57b76272ba94d770/96baa43/src/domain.rs:393:3: 393:31
    = note: inside `bitvec::slice::BitSlice::<u8, bitvec::order::Msb0>::domain` at /home/wcampbell/.cargo/git/checkouts/bitvec-57b76272ba94d770/96baa43/src/slice.rs:1026:3: 1026:20
note: inside `impls::primitive::<impl DekuRead<'_, (ctx::Endian, ctx::ByteSize)> for u8>::read`
   --> src/impls/primitive.rs:35:16
    |
35  |             && bit_slice.domain().region().unwrap().1.len() * 8 == MAX_TYPE_BITS
    |                ^^^^^^^^^^^^^^^^^^
note: inside `impls::primitive::<impl DekuRead<'_, ctx::Endian> for u8>::read`
   --> src/impls/primitive.rs:278:21
    |
278 |                     <$typ>::read(input, (endian, ByteSize(bit_size.0 / 8)))
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
502 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::primitive::<impl DekuRead<'_> for u8>::read`
   --> src/impls/primitive.rs:319:17
    |
319 |                 <$typ>::read(input, Endian::default())
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
502 | ImplDekuTraits!(u8);
    | ------------------- in this macro invocation
note: inside `impls::bool::<impl DekuRead<'_> for bool>::read`
   --> src/impls/bool.rs:18:27
    |
18  |         let (rest, val) = u8::read(input, inner_ctx)?;
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool`
   --> src/impls/bool.rs:61:32
    |
61  |         let (rest, res_read) = bool::read(bit_slice, ()).unwrap();
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `impls::bool::tests::test_bool::case_1`
   --> src/impls/bool.rs:52:5
    |
52  | /     #[rstest(input, expected,
53  | |         case(&hex!("00"), false),
54  | |         case(&hex!("01"), true),
55  | |
56  | |         #[should_panic(expected = "Parse(\"cannot parse bool value: 2\")")]
57  | |         case(&hex!("02"), false),
58  | |     )]
    | |______^
note: inside closure
   --> src/impls/bool.rs:52:5
    |
52  |     #[rstest(input, expected,
    |     ^
    = note: this error originates in the macro `ForwardDekuRead` which comes from the expansion of the attribute macro `rstest` (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`

Caused by:
  process didn't exit successfully: `/home/wcampbell/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner /home/wcampbell/projects/wcampbell/deku/target/miri/x86_64-unknown-linux-gnu/debug/deps/deku-1e68a843a6e0d7a7` (exit status: 1)

@wcampbell0x2a
Copy link
Collaborator Author

Fixed with the MR ferrilab/bitvec#266, who knows when this will be merged.

@wcampbell0x2a wcampbell0x2a removed the bug Something isn't working label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants