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
Rustc started to add runtime checks for pointer alignment when running with debug assertions (rust-lang/rust#98112), and I'm hitting this with pure ndarray code (the assertion comes from inside matrixmultiply, I can move the issue there if you prefer). Here is the code to reproduce:
$ RUST_BACKTRACE=1 cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/unaligned-ndarray`
thread 'main' panicked at 'misaligned pointer dereference: address must be a multiple of 0x10 but is 0x13df040d8', ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/gemm.rs:395:43
stack backtrace:
0: rust_begin_unwind
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
1: core::panicking::panic_nounwind_fmt
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:96:14
2: core::panicking::panic_misaligned_pointer_dereference
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:175:5
3: matrixmultiply::gemm::gemm_packed::{{closure}}::{{closure}}
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/gemm.rs:395:43
4: std::thread::local::LocalKey<T>::try_with
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/thread/local.rs:270:16
5: std::thread::local::LocalKey<T>::with
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/thread/local.rs:246:9
6: matrixmultiply::gemm::gemm_packed::{{closure}}
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/gemm.rs:395:23
7: matrixmultiply::threading::RangeChunkParallel<G>::for_each
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/threading.rs:220:25
8: matrixmultiply::gemm::gemm_packed
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/gemm.rs:384:5
9: matrixmultiply::gemm::gemm_loop::{{closure}}
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/gemm.rs:327:21
10: matrixmultiply::threading::RangeChunkParallel<G>::for_each
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/threading.rs:222:13
11: matrixmultiply::gemm::gemm_loop
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/gemm.rs:310:13
12: <matrixmultiply::gemm::GemmParameters<T> as matrixmultiply::kernel::GemmSelect<T>>::select
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/gemm.rs:211:13
13: matrixmultiply::dgemm_kernel::detect
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/dgemm_kernel.rs:65:20
14: matrixmultiply::gemm::dgemm
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matrixmultiply-0.3.7/src/gemm.rs:91:5
15: ndarray::linalg::impl_linalg::mat_mul_general
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/linalg/impl_linalg.rs:527:13
16: <ndarray::ArrayBase<S,ndarray::dimension::dim::Dim<[usize; 2]>> as ndarray::linalg::impl_linalg::Dot<ndarray::ArrayBase<S2,ndarray::dimension::dim::Dim<[usize; 2]>>>>::dot
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/linalg/impl_linalg.rs:286:9
17: ndarray::linalg::impl_linalg::<impl ndarray::ArrayBase<S,ndarray::dimension::dim::Dim<[usize; 2]>>>::dot
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/linalg/impl_linalg.rs:257:9
18: unaligned_ndarray::main
at ./src/main.rs:22:13
19: core::ops::function::FnOnce::call_once
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread caused non-unwinding panic. aborting.
The text was updated successfully, but these errors were encountered:
Thanks for the report, I think the error is a bit frustrating since matrixmultiply handles the pointer alignment correctly if it just can be allowed to continue on the next line of code. I have a bit of deja vu, thought I had handled this once before.
(turns out it's deja vu since I lowered it to 16-byte before, "worked - and still did - for me")
Rustc started to add runtime checks for pointer alignment when running with debug assertions (rust-lang/rust#98112), and I'm hitting this with pure ndarray code (the assertion comes from inside matrixmultiply, I can move the issue there if you prefer). Here is the code to reproduce:
Running this give this panic & backtrace:
The text was updated successfully, but these errors were encountered: