-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Description:
I have a signal with 3,600,032 values and I am computing its FFT. On a 64-bit system, this works perfectly, but on a 32-bit system, it causes an overflow. I am using rustfft in WebAssembly, and currently only 32-bit is available.
The problem is related to the size of usize. As soon as I decrease or increase my vector by a single element, it works fine again, but I assume that Rader's algorithm is no longer being used in that case.
Steps to Reproduce:
Set Rust override: rustup override set 1.85
Add 32-bit Linux target: rustup target add i686-unknown-linux-gnu
Run the demo with backtrace enabled: RUST_BACKTRACE=1 cargo run --target i686-unknown-linux-gnu
Error:
thread 'main' panicked at /home/dev/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustfft-6.4.0/src/algorithm/raders_algorithm.rs:94:29: attempt to multiply with overflow
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic_const::panic_const_mul_overflow
3: rustfft::algorithm::raders_algorithm::RadersAlgorithm<T>::new
4: rustfft::plan::FftPlannerScalar<T>::build_new_fft
5: rustfft::plan::FftPlannerScalar<T>::build_fft
...
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
Screenshots / Logs / Demo:
I have prepared a minimal demo that reproduces the issue, which can be attached here.
Environment:
Operating System: 32-bit Linux (i686)
Rust Version: 1.85
rustfft Version: 6.4.0
WebAssembly target: yes
Additional Information:
- The overflow seems to be caused by the size of usize on 32-bit systems.
- Changing the vector length by one element avoids the overflow, likely bypassing Rader's algorithm.