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

misaligned pointer in queue::Queue::get #3795

Open
shinmao opened this issue Sep 12, 2023 · 3 comments
Open

misaligned pointer in queue::Queue::get #3795

shinmao opened this issue Sep 12, 2023 · 3 comments

Comments

@shinmao
Copy link

shinmao commented Sep 12, 2023

The source of unsoundness

fn get<T>(data: &[u8], ptr: com::BufferSlice) -> &[T] {
let u32_size = mem::size_of::<T>();
assert_eq!(ptr.size % u32_size as u32, 0);
let raw = Self::get_raw(data, ptr);
unsafe { slice::from_raw_parts(raw.as_ptr() as *const _, raw.len() / u32_size) }

We consider that queue::Queue::get is unsound because the program tried to cast u8 slice to f32/f64/i32 and created a unaligned pointer. The unaligned pointer was passed to slice::from_raw_parts which requires the guarantee of pointer's alignment.

@cwfitzgerald
Copy link
Member

Thanks for the issue - gfx is in maintainence mode. If you can submit a PR we'll merge it, but otherwise I wouldn't expect this to be fixed.

@maxwellflitton
Copy link

@cwfitzgerald considering that this is in maintenance mode, is there another library that is actively maintained that is a GPU interface?

@cwfitzgerald
Copy link
Member

If you want vulkan bindings, use https://crates.io/crates/ash, if you want a safe interface to the gpu, use https://crates.io/crates/wgpu

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