fast_image_resize
fast_image_resize copied to clipboard
Floating point exception during convolutional downscale (Lanczos)
GDB Backtrace:
(gdb) bt
#0 0x0000737952d91d4a in do_cos (dx=6.123233995736766e-17, x=<optimized out>) at ../sysdeps/ieee754/dbl-64/s_sin.c:107
#1 __sin_fma (x=1.3089969389957472) at ../sysdeps/ieee754/dbl-64/s_sin.c:229
#2 0x000064776f8ab601 in core::ops::function::Fn::call ()
#3 0x000064776f8bd552 in fast_image_resize::convolution::precompute_coefficients ()
#4 0x000064776f8af97b in fast_image_resize::resizer::resample_convolution ()
#5 0x000064776f8adc0c in fast_image_resize::resizer::Resizer::resize ()
#6 0x000064776f5176e2 in blackbox_core::capture::preview::resize_frame ()
#7 0x000064776f514b01 in blackbox_core::capture::preview::preview_manager_thread ()
#8 0x000064776f54c225 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#9 0x000064776f6b0fc9 in core::ops::function::FnOnce::call_once{{vtable.shim}} ()
#10 0x000064776fedecb5 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2007
#11 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2007
#12 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#13 0x0000737951294ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#14 0x0000737951326850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
This issue is incredibly rare; my application does this roughly 40 times per second and it takes roughly an hour for it to happen, but it does happen unconditionally given enough time. Let me know if there's any information that would be useful.
Could you tell me sizes of source and destination images that cause this error?
According to your traceback, it looks like the error occurs somewhere in this code:
#[inline]
fn lanczos_filter(x: f64) -> f64 {
// truncated sinc
if (-3.0..3.0).contains(&x) {
sinc_filter(x) * sinc_filter(x / 3.)
} else {
0.0
}
}
#[inline]
fn sinc_filter(mut x: f64) -> f64 {
if x == 0.0 {
1.0
} else {
x *= PI;
x.sin() / x
}
}
But I have no idea what value of x
might be causing the problem.
I am downscaling from 2048x2048 to 1024x1024
According to your traceback,
__sin_fma (x=1.3089969389957472) at ../sysdeps/ieee754/dbl-64/s_sin.c:229
the exception occurred due to calling __sin(x) function with x: f64 = 1.3089969389957472
But value 1.3089969389957472
isn't special in any meanings.
I didn't able to reproduce your exception during downscaling from 2048x2048 to 1024x1024. Also I couldn't reproduce the exception during direct call of x.sin()
where x
is 1.3089969389957472f64
.