SimSIMD icon indicating copy to clipboard operation
SimSIMD copied to clipboard

Bug: cargo test crashes on i386

Open tenzap opened this issue 2 months ago • 5 comments

Describe the bug

While running the test suite of the Debian package on x86 (i386) architecture, we found that the tests are crashing (signal: 11, SIGSEGV: invalid memory reference)

Could you have a look?

This also crashed with 6.4.0

There is no crash on the other archs and tests pass.

Steps to reproduce

Command: ['env', 'RUST_BACKTRACE=1', '/usr/bin/cargo', '-Zavoid-dev-deps', 'test', '--verbose', '--verbose', '-j4', '--target', 'i686-unknown-linux-gnu', '--all-targets', '--all-features']

Full log for 6.5.3 available at https://debusine.debian.net/debian/developers/artifact/2529250/file/rust-simsimd:@-stdout Full log for 6.4.0 at https://ci.debian.net/data/autopkgtest/testing/i386/r/rust-simsimd/64843062/artifacts.tar.gz

Expected behavior

no crash

SimSIMD version

6.5.3

Operating System

Debian unstable

Hardware architecture

x86

Which interface are you using?

C implementation

Contact Details

No response

Are you open to being tagged as a contributor?

  • [ ] I am open to being mentioned in the project .git history as a contributor

Is there an existing issue for this?

  • [x] I have searched the existing issues

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

tenzap avatar Sep 30 '25 09:09 tenzap

Hi @tenzap! It's a pretty long dump and I'm not sure about where to look. Is there a specific test you can point me to?

ashvardanian avatar Sep 30 '25 12:09 ashvardanian

Thanks for considering this.

Unfortunately not. The dump looks long because in Debian the build system prints all commands to build all rust dependencies. But you are mostly interested in the last one which is the one of simsimd.

When running the test it crashes almost immediately on when starting to run the tests of simsimd. Just try yourself with i686. I'm not even sure the 1st test can actually finish.

I can't really help more sorry.

tenzap avatar Sep 30 '25 12:09 tenzap

Hello, if it is of any help, I tried recording it with rr-debugger and received on replay this backtrace:

benutzer@debian:~/source/rust-simsimd/try1/rust-simsimd-6.4.0$ rr record /usr/share/cargo/bin/cargo-auto-test simsimd 6.4.0 --all-targets --all-features
rr: Saving execution to trace directory `/home/benutzer/.local/share/rr/cargo-auto-test-0'.
...
running 23 tests
test tests::test_cos_bf16_interop ... error: test failed, to rerun pass `--lib`

Caused by:
  process didn't exit successfully: `CARGO=/usr/bin/cargo CARGO_MANIFEST_DIR=/usr/share/cargo/registry/simsimd-6.4.0 CARGO_MANIFEST_PATH=/usr/share/cargo/registry/simsimd-6.4.0/Cargo.toml CARGO_PKG_AUTHORS='Ash Vardanian <[email protected]>' CARGO_PKG_DESCRIPTION='Portable mixed-precision BLAS-like vector math library for x86 and ARM' CARGO_PKG_HOMEPAGE='https://ashvardanian.com/posts/simsimd-faster-scipy' CARGO_PKG_LICENSE=Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=simsimd CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/ashvardanian/SimSIMD' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=6.4.0 CARGO_PKG_VERSION_MAJOR=6 CARGO_PKG_VERSION_MINOR=4 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/build/simsimd-95b690057e60a15a/out:/tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/deps:/tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug:/usr/lib/rustlib/i686-unknown-linux-gnu/lib' OUT_DIR=/tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/build/simsimd-95b690057e60a15a/out /tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/deps/simsimd-db4e1ed3b83bc5d0` (signal: 11, SIGSEGV: invalid memory reference)


benutzer@debian:~/source/rust-simsimd/try1/rust-simsimd-6.4.0$ rr ps
...
16565   15723   -11     /tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/deps/simsimd-db4e1ed3b83bc5d0
...


benutzer@debian:~/source/rust-simsimd/try1/rust-simsimd-6.4.0$ rr replay --debugger-option=-q -p 16565 cargo-auto-test-0
...
(rr) set width 0
(rr) set pagination off
(rr) cont
Continuing.
     Running `CARGO=/usr/bin/cargo CARGO_MANIFEST_DIR=/usr/share/cargo/registry/simsimd-6.4.0 CARGO_MANIFEST_PATH=/usr/share/cargo/registry/simsimd-6.4.0/Cargo.toml CARGO_PKG_AUTHORS='Ash Vardanian <[email protected]>' CARGO_PKG_DESCRIPTION='Portable mixed-precision BLAS-like vector math library for x86 and ARM' CARGO_PKG_HOMEPAGE='https://ashvardanian.com/posts/simsimd-faster-scipy' CARGO_PKG_LICENSE=Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=simsimd CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/ashvardanian/SimSIMD' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=6.4.0 CARGO_PKG_VERSION_MAJOR=6 CARGO_PKG_VERSION_MINOR=4 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/build/simsimd-95b690057e60a15a/out:/tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/deps:/tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug:/usr/lib/rustlib/i686-unknown-linux-gnu/lib' OUT_DIR=/tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/build/simsimd-95b690057e60a15a/out /tmp/tmp.EXaqvfceTj/target/i686-unknown-linux-gnu/debug/deps/simsimd-db4e1ed3b83bc5d0`

running 23 tests
test tests::test_cos_bf16_interop ... [New Thread 16565.16566]

Thread 2 received signal SIGSEGV, Segmentation fault.
0x00435c6c in simsimd_cos_bf16_serial (a=0xb7800760, b=0xb7800770, n=13245819878352355331, result=0x2) at include/simsimd/spatial.h:239
239     SIMSIMD_MAKE_COS(serial, bf16, f32, SIMSIMD_BF16_TO_F32)  // simsimd_cos_bf16_serial
(rr) bt
#0  0x00435c6c in simsimd_cos_bf16_serial (a=0xb7800760, b=0xb7800770, n=13245819878352355331, result=0x2) at include/simsimd/spatial.h:239
#1  0x00433e9d in simsimd::{impl#7}::cos (a=..., b=...) at rust/lib.rs:486
#2  0x00429f54 in simsimd::SpatialSimilarity::cosine<simsimd::bf16> (a=..., b=...) at rust/lib.rs:259
#3  0x00432134 in simsimd::tests::test_cos_bf16_interop () at rust/lib.rs:1152
#4  0x0042aae9 in simsimd::tests::test_cos_bf16_interop::{closure#0} () at rust/lib.rs:1134
#5  0x0042ba5e in core::ops::function::FnOnce::call_once<simsimd::tests::test_cos_bf16_interop::{closure_env#0}, ()> () at /usr/src/rustc-1.89.0/library/core/src/ops/function.rs:250
#6  0x0044620d in core::ops::function::FnOnce::call_once<fn() -> core::result::Result<(), alloc::string::String>, ()> () at library/core/src/ops/function.rs:250
#7  test::__rust_begin_short_backtrace<core::result::Result<(), alloc::string::String>, fn() -> core::result::Result<(), alloc::string::String>> (f=0x42ba30 <core::ops::function::FnOnce::call_once<simsimd::tests::test_cos_bf16_interop::{closure_env#0}, ()>>) at library/test/src/lib.rs:648
#8  0x0045e3e7 in test::types::RunnableTest::run (self=...) at library/test/src/types.rs:145
#9  0x004463ec in test::run_test_in_process::{closure#0} () at library/test/src/lib.rs:671
#10 core::panic::unwind_safe::{impl#23}::call_once<core::result::Result<(), alloc::string::String>, test::run_test_in_process::{closure_env#0}> (self=...) at library/core/src/panic/unwind_safe.rs:272
#11 std::panicking::catch_unwind::do_call<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>, core::result::Result<(), alloc::string::String>> (data=<error reading variable: Cannot access memory at address 0x0>) at library/std/src/panicking.rs:589
#12 std::panicking::catch_unwind<core::result::Result<(), alloc::string::String>, core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>> (f=...) at library/std/src/panicking.rs:552
#13 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>, core::result::Result<(), alloc::string::String>> (f=...) at library/std/src/panic.rs:359
#14 test::run_test_in_process (id=..., desc=..., nocapture=<optimized out>, report_time=<optimized out>, runnable_test=..., monitor_ch=..., time_opts=...) at library/test/src/lib.rs:671
#15 0x0044def6 in test::run_test::{closure#0} () at library/test/src/lib.rs:592
#16 test::run_test::{closure#1} () at library/test/src/lib.rs:622
#17 std::sys::backtrace::__rust_begin_short_backtrace<test::run_test::{closure_env#1}, ()> (f=...) at library/std/src/sys/backtrace.rs:152
#18 0x0046b876 in std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure#0}<test::run_test::{closure_env#1}, ()> () at library/std/src/thread/mod.rs:559
#19 core::panic::unwind_safe::{impl#23}::call_once<(), std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>> (self=<error reading variable: Cannot access memory at address 0xc>) at library/core/src/panic/unwind_safe.rs:272
#20 std::panicking::catch_unwind::do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>, ()> (data=<error reading variable: Cannot access memory at address 0x0>) at library/std/src/panicking.rs:589
#21 std::panicking::catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>> (f=...) at library/std/src/panicking.rs:552
#22 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>, ()> (f=...) at library/std/src/panic.rs:359
#23 std::thread::{impl#0}::spawn_unchecked_::{closure#1}<test::run_test::{closure_env#1}, ()> () at library/std/src/thread/mod.rs:557
#24 core::ops::function::FnOnce::call_once<std::thread::{impl#0}::spawn_unchecked_::{closure_env#1}<test::run_test::{closure_env#1}, ()>, ()> () at library/core/src/ops/function.rs:250
#25 0x004a6e61 in alloc::boxed::{impl#28}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> (self=..., args=<optimized out>) at library/alloc/src/boxed.rs:1966
#26 std::sys::pal::unix::thread::{impl#2}::new::thread_start (data=0xa17ab0) at library/std/src/sys/pal/unix/thread.rs:107
#27 0xb7dbd781 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:448
#28 0xb7e53c46 in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:107
(rr) display/i $pc
1: x/i $pc
=> 0x435c6c <simsimd_cos_bf16_serial+332>:      fstpl  (%eax)
(rr) print/x $eax
$1 = 0x2
(rr) info local
ab = 32
a2 = <optimized out>
b2 = <optimized out>
(rr) info thread
  Id   Target Id                                     Frame 
  1    Thread 16565.16565 (simsimd-db4e1ed3b83bc5d0) 0x70000002 in ?? ()
* 2    Thread 16565.16566 (simsimd-db4e1ed3b83bc5d0) 0x00435c6c in simsimd_cos_bf16_serial (a=0xb7800760, b=0xb7800770, n=13245819878352355331, result=0x2) at include/simsimd/spatial.h:239
(rr)

bernhardu avatar Oct 18 '25 22:10 bernhardu

@ashvardanian, as you can see, this issue blocks the migration of simsimd to Debian testing. I'm sorry I can't help more, but it would be great if there was a fix for this failing test in simsimd on i386.

tenzap avatar Nov 11 '25 13:11 tenzap

Hi @tenzap! I'm working on the SimSIMD minor release right now and will try patching this soon. Thanks!

ashvardanian avatar Nov 11 '25 17:11 ashvardanian

I can confirm that the fix on the main-dev branch fixes the unit test errors.

alexanderkjall avatar Nov 24 '25 18:11 alexanderkjall