grovesNL / glow

GL on Whatever: a set of bindings to run GL anywhere and avoid target-specific code
Apache License 2.0
1.21k stars 130 forks source link

Cheeky Unsoundness Now Asserts in New Rust #327

Open cwfitzgerald opened 2 weeks ago

cwfitzgerald commented 2 weeks ago

https://github.com/grovesNL/glow/blob/cf08bc4e2f99e7e7152d53bf08273bd6316b5a22/src/web_sys.rs#L6165-L6215

The cheeky casts here are causing slice::from_raw_parts to error out due to the lack of alignment. I don't know if the views themselves are required to be aligned, but if you don't put aligned data into glow, it gets mad. Probably needs view_mut_raw

panicked at library/core/src/panicking.rs:221:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f/<@http://localhost:8888/assets/index-B7R0YP-3.js:7482:19
logError@http://localhost:8888/assets/index-B7R0YP-3.js:7192:15
__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@http://localhost:8888/assets/index-B7R0YP-3.js:7481:12
client.wasm.console_error_panic_hook::Error::new::hc69b5fa529afea52@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[9801]:0x4af724
client.wasm.console_error_panic_hook::hook_impl::hf10585ca8c9ba013@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[2694]:0x367907
client.wasm.console_error_panic_hook::hook::h4ee3fc12c0aca055@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[14330]:0x4f99cd
client.wasm.core::ops::function::Fn::call::h0d9ba157495fc0df@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[11813]:0x4d5cbe
client.wasm.std::panicking::rust_panic_with_hook::h33fe77d38d305ca3@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[5025]:0x40a9e1
client.wasm.std::panicking::begin_panic_handler::{{closure}}::h98de848d678bad07@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[6866]:0x45b7ee
client.wasm.std::sys::backtrace::__rust_end_short_backtrace::h2bcfc60c3cf0a312@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[15938]:0x50976e
client.wasm.rust_begin_unwind@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[10697]:0x4c1beb
client.wasm.core::panicking::panic_nounwind_fmt::hd2fee749e9eab1f3@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[10698]:0x4c1c3e
client.wasm.core::panicking::panic_nounwind::h1c2f45581e84758f@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[12064]:0x4d9c8e
client.wasm.core::slice::raw::from_raw_parts::precondition_check::hb66aef015918d8d0@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[2271]:0x33b088
client.wasm.core::slice::raw::from_raw_parts::h5e5801e03f4aea99@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[10334]:0x4ba800
client.wasm.glow::web::texture_data_view::hd5077806e43852fd@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[1007]:0x26619c
client.wasm.<glow::web::Context as glow::HasContext>::tex_image_2d::{{closure}}::haa471d6d7e5a6efd@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[9844]:0x4b05a8
client.wasm.core::option::Option<T>::map::h30ad24a51c9ae128@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[5728]:0x42cf1c
client.wasm.<glow::web::Context as glow::HasContext>::tex_image_2d::h72e31b182d00508e@http://localhost:8888/assets/client_bg-PjZmLhTd.wasm:wasm-function[1803]:0x2ffc6a