Skip to content

Fix some crashes zooming into blurred objects

Nathan Lee requested to merge nathanal/inkscape:inbox4406 into master

Sometimes the DrawingContext given to the filter in DrawingItem::render has a width but no height.

See https://gitlab.com/inkscape/inbox/-/issues/4406 or !2965 (merged)


Example file where this crash would be triggered: MovesList5.svg.

I couldn't figure out how to read the Geom::OptIntRect values but in DrawingItem::render,

  1. we use Geom::OptIntRect iarea
  2. we return if !iarea by line 718
  3. we don't change iarea again by the time we create DrawingContext ictor render the filter. ict has no width at this point, at least when we crash.

Backtrace this crash aims to address

Thread 1 "inkscape" received signal SIGSEGV, Segmentation fault.
0x00007ffff6d6830e in Inkscape::Filters::_ZN8Inkscape7FiltersL12filter2D_FIRIhLj4EEEvPT_iiPKS2_iiiiPKNS_4Util10FixedPointIjLj16EEEii._omp_fn.0(void) ()
    at ../src/display/nr-filter-gaussian.cpp:382
382	#pragma omp parallel for num_threads(num_threads) private(history)
(gdb) bt
#0  0x00007ffff6d6830e in Inkscape::Filters::_ZN8Inkscape7FiltersL12filter2D_FIRIhLj4EEEvPT_iiPKS2_iiiiPKNS_4Util10FixedPointIjLj16EEEii._omp_fn.0(void) ()
    at ../src/display/nr-filter-gaussian.cpp:382
#1  0x00007ffff34d68e6 in GOMP_parallel ()
    at /usr/lib/x86_64-linux-gnu/libgomp.so.1
#2  0x00007ffff6d663cc in Inkscape::Filters::filter2D_FIR<unsigned char, 4>(unsigned char*, int, int, unsigned char const*, int, int, int, int, FIRValue const*, int, int)
    (dst=<optimised out>, dstr1=dstr1@entry=0, dstr2=dstr2@entry=4, src=src@entry=0x0, sstr1=sstr1@entry=0, sstr2=sstr2@entry=4, n1=0, n2=186, kernel=0x555559ff4090, scr_len=1, num_threads=4) at ../src/display/nr-filter-gaussian.cpp:373
#3  0x00007ffff6d66f06 in Inkscape::Filters::gaussian_pass_FIR(Geom::Dim2, double, cairo_surface_t*, cairo_surface_t*, int)
    (d=d@entry=Geom::Y, deviation=deviation@entry=0.0011208060290487224, src=src@entry=0x555559fe08f0, dest=dest@entry=0x555559fe08f0, num_threads=num_threads@entry=4) at /usr/include/c++/9/bits/stl_vector.h:1040
#4  0x00007ffff6d67beb in Inkscape::Filters::FilterGaussian::render_cairo(Inkscape::Filters::FilterSlot&) (this=0x555557f55990, slot=...)
    at ../src/display/nr-filter-gaussian.cpp:671

https://gitlab.com/inkscape/inbox/uploads/74308d743288af7036b6367124b9618e/inkscape_backtrace_catch_throw_blur.txt

Edited by Nathan Lee

Merge request reports