You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been developing an experimental version of Miri that can execute foreign functions by interpreting LLVM bytecode.
Miri found the following error when executing the test webp_data::tests::test_encoder at version 0.9.0 of webp-animation.
error: Undefined Behavior: dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
--> .../rust/library/core/src/slice/raw.rs:101:9
|
101 | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
|
= 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: BACKTRACE:
= note: inside `std::slice::from_raw_parts::<'_, u8>` at .../rust/library/core/src/slice/raw.rs:101:9: 101:47
note: inside `webp_data::WebPData::as_slice`
--> src/webp_data.rs:27:18
|
27 | unsafe { slice::from_raw_parts(self.data.bytes, self.data.size) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `<webp_data::WebPData as std::ops::Deref>::deref`
--> src/webp_data.rs:41:9
|
41 | self.as_slice()
| ^^^^^^^^^^^^^^^
note: inside `webp_data::tests::test_encoder`
--> src/webp_data.rs:58:20
|
58 | assert_eq!(data.len(), 0);
| ^^^^^^^^^^
note: inside closure
--> src/webp_data.rs:56:23
|
55 | #[test]
| ------- in this procedural macro expansion
56 | fn test_encoder() {
|
It seems like WebPData::new() does not actually initialize the WebPData struct to point to valid memory. In particular, here's where data is initialized in Rust:
let mut data = mem::zeroed();
webp::WebPDataInit(&mut data);
data
It seems like webp::WebPDataInit just zero-initializes the memory that it's passed:
However, this shouldn't be necessary, since the memory being referenced has already been initialized by mem::zeroed() in Rust. Anyway, it seems like the implementation of WebPData::as_slice needs to account for the case when data is NULL.
The text was updated successfully, but these errors were encountered:
I've been developing an experimental version of Miri that can execute foreign functions by interpreting LLVM bytecode.
Miri found the following error when executing the test
webp_data::tests::test_encoder
at version 0.9.0 of webp-animation.It seems like
WebPData::new()
does not actually initialize theWebPData
struct to point to valid memory. In particular, here's wheredata
is initialized in Rust:It seems like
webp::WebPDataInit
just zero-initializes the memory that it's passed:However, this shouldn't be necessary, since the memory being referenced has already been initialized by
mem::zeroed()
in Rust. Anyway, it seems like the implementation ofWebPData::as_slice
needs to account for the case whendata
isNULL
.The text was updated successfully, but these errors were encountered: