rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
731 stars 135 forks source link

num-traits: testsuite failure on i386 #124

Closed LocutusOfBorg closed 5 years ago

LocutusOfBorg commented 5 years ago

Hello, looks like a test is failing on i386 since the begin (at least since version 2)

test wrapping_is_num ... ok
test check_num_ops ... ok
test ops::mul_add::tests::mul_add_float ... FAILED

failures:

---- ops::mul_add::tests::mul_add_float stdout ----
thread 'ops::mul_add::tests::mul_add_float' panicked at 'assertion failed: abs_difference <= f32::EPSILON', src/ops/mul_add.rs:149:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::panicking::panic
   9: num_traits::ops::mul_add::tests::mul_add_float
             at src/ops/mul_add.rs:149
  10: num_traits::ops::mul_add::tests::mul_add_float::{{closure}}
             at src/ops/mul_add.rs:130
  11: core::ops::function::FnOnce::call_once
             at /usr/src/rustc-1.34.2/src/libcore/ops/function.rs:231

failures:
    ops::mul_add::tests::mul_add_float

test result: FAILED. 25 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '--lib'
dh_auto_test: /usr/share/cargo/bin/cargo test --all returned exit code 101
make[1]: *** [debian/rules:6: override_dh_auto_test] Error 25
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:3: build-arch] Error 2
dpkg-buildpackage: error: debian/rules build-arch subprocess returned exit status 2
--------------------------------------------------------------------------------
Build finished at 2019-07-08T08:08:37Z

Do you have any idea?

Full build log: https://buildd.debian.org/status/fetch.php?pkg=rust-num-traits&arch=i386&ver=0.2.8-1&stamp=1562573322&raw=0

cuviper commented 5 years ago

Hmm, I can reproduce this on i586-unknown-linux-gnu, but not on i686. The main difference is in the default target features, where Rust i686 assumes fxsr,sse,sse2, and this could certainly have an effect on the accuracy that this test is looking for.

But I can see in your log that it did build for i686 -- unless Debian patched out the SSE features? (Not all i686 CPUs really have SSE2, after all.) What does rustc --print cfg say?

I can reproduce on i686 with RUSTFLAGS='-Ctarget-feature=-sse', so I suspect this is it.

Anyway, the test is probably just too tight with comparing EPSILON, "the difference between 1.0 and the next largest representable number." The true decimal result is 46.4, so EPSILON is already out of the range of significant bits, and we're effectively comparing for equality.