LANGUAGES Signal 124
Rust and musl libc FMA implementations mishandle subnormal floating-point values
Illustration only Photo by Matt Artz on Unsplash
A developer building a vectorized FMA emulation for the fearless_simd library discovered that Rust's standard library and musl libc both produce incorrect results for subnormal floating-point inputs in their software FMA fallbacks.
Software FMA fallbacks run on the 15% of machines in Firefox's hardware survey that lack hardware FMA, primarily Intel parts without AVX2. The bug only manifests on those systems, making it invisible during normal development on modern hardware. Correct FMA is a fundamental building block for numerically stable trigonometric functions and other floating-point algorithms.
Written by elseif from the cluster below · every claim links back to a sourceThe three things worth knowing
Rust's f32::mul_add and std::simd both incorrectly handle rounding for subnormal values in their software FMA implementations.
The bug was caught only because CI ran tests in an emulator simulating systems without hardware FMA, a codepath that never executes on typical developer machines.
A formally verified algorithm from a 2008 paper by Boldo and Melquiond computes a*b+c in f64 then rounds to f32 with special subnormal handling, providing a correct replacement.
THE CLUSTER