-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fails with "unsafe precondition(s) violated" since Rust 1.78 #7
Comments
I think that this error is occurred inside the function unsafe extern "C" fn read(data: *mut c_void, size: usize, user_data: *mut c_void) -> c_int {
let reader = &mut *(user_data as *mut Box<dyn Reader>);
let buf = slice::from_raw_parts_mut(data as *mut u8, size);
match reader.read(buf) {
Ok(real_size) if real_size == buf.len() => 0,
_ => 1,
}
} It seems like Could you give me an example of code (and heif-file) to reproduce this error? |
What architecture were you running the code on when you got this error? Is it 32-bit architecture? |
Not tested on 32bit but my CI started failing for amd64 and aarch64 when updating to Rust 1.78 and my Desktop (amd64) as well. |
I will try to create a minimal reproducer later. The original code is a bit involved. |
pub fn main() {
let data = std::fs::read("color.avif").unwrap();
let len = data.len() as u64;
let stream_reader = libheif_rs::StreamReader::new(std::io::Cursor::new(data), len);
libheif_rs::HeifContext::read_from_reader(Box::new(stream_reader)).unwrap();
} It seems to happen with all avif pictures but not heic. For completeness here is an image https://gitlab.gnome.org/sophie-h/test-images/-/blob/main/images/color/color.avif |
I have checked. const size_t configOBUs_bytes = range.get_remaining_bytes();
m_config_OBUs.resize(configOBUs_bytes);
if (!range.read(m_config_OBUs.data(), configOBUs_bytes)) {
// error
} Here I've added the handling of this case into |
Thanks a lot! |
heif_context_read_from_reader
calls triggersI did not call it directly but used
HeifContext::read_from_reader
. But I guess the issue here is the design of the slice types used?rust-lang/rust#123285
The text was updated successfully, but these errors were encountered: