-
-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Labels
Description
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'