Project

General

Profile

Bug #10344

Crash in lens correction module (distortion)

Added by Matthieu Moy about 5 years ago. Updated almost 5 years ago.

Status:
Fixed
Priority:
Low
Assignee:
Category:
Darkroom
Start date:
02/26/2015
Due date:
% Done:

100%

Estimated time:
Affected Version:
git development version
System:
Debian
bitness:
64-bit
hardware architecture:
amd64/x86

Description

Darktable reproducibly crashes for me when all these conditions are met:

  • The lens is Nikon AF-S DX Nikkor 10-24mm f/3.5-4.5G ED
  • The focal length is 10 mm (it doesn't crash with others)
  • The correction includes "distortion"
  • The distortion mode is set to "orthographic"

I have a lenfun 0.2.8-2 installed, and backported my camera's setting in /usr/share/lensfun/slr-nikon.xml :

<lens>
<maker>Nikon</maker>
<model>Nikon AF-S DX Nikkor 10-24mm f/3.5-4.5G ED</model>
<model lang="en">Nikkor AF-S 10-24mm f/3.5-4.5G DX ED</model>
<mount>Nikon F AF</mount>
<cropfactor>1.523</cropfactor>
<calibration>
<!-- Taken with Nikon D3100 -->
<distortion model="ptlens" focal="10" a="0.0054" b="-0.04682" c="0.05708" />
<distortion model="ptlens" focal="12" a="-0.00189" b="-0.01666" c="0.03458" />
<distortion model="ptlens" focal="15" a="-0.00516" b="0.00567" c="0.01351" />
<distortion model="ptlens" focal="18" a="-0.0069" b="0.02453" c="-0.02009" />
<distortion model="ptlens" focal="20" a="-0.00605" b="0.02554" c="-0.02419" />
<distortion model="ptlens" focal="24" a="0.00279" b="-0.00922" c="0.01907" />
<tca model="poly3" focal="10" vr="1.00043" vb="1.00014" />
<tca model="poly3" focal="12" vr="1.00047" vb="1" />
<tca model="poly3" focal="15" vr="1.00030" vb="1" />
<tca model="poly3" focal="18" vr="1.00020" vb="1" />
<tca model="poly3" focal="20" vr="1.00020" vb="1" />
<tca model="poly3" focal="24" vr="1.00016" vb="1" />
<!-- Taken with Nikon D5100 -->
<vignetting model="pa" focal="10" aperture="3.5" distance="10" k1="-0.6853" k2="0.2007" k3="-0.0649" />
<vignetting model="pa" focal="10" aperture="3.5" distance="1000" k1="-0.6853" k2="0.2007" k3="-0.0649" />
<vignetting model="pa" focal="10" aperture="4.5" distance="10" k1="-0.6419" k2="0.2700" k3="-0.1483" />
<vignetting model="pa" focal="10" aperture="4.5" distance="1000" k1="-0.6419" k2="0.2700" k3="-0.1483" />
<vignetting model="pa" focal="10" aperture="5.6" distance="10" k1="-0.7370" k2="0.5622" k3="-0.2863" />
<vignetting model="pa" focal="10" aperture="5.6" distance="1000" k1="-0.7370" k2="0.5622" k3="-0.2863" />
<vignetting model="pa" focal="10" aperture="6.3" distance="10" k1="-0.7084" k2="0.4323" k3="-0.1541" />
<vignetting model="pa" focal="10" aperture="6.3" distance="1000" k1="-0.7084" k2="0.4323" k3="-0.1541" />
<vignetting model="pa" focal="10" aperture="22" distance="10" k1="-0.7137" k2="0.4318" k3="-0.1499" />
<vignetting model="pa" focal="10" aperture="22" distance="1000" k1="-0.7137" k2="0.4318" k3="-0.1499" />
<vignetting model="pa" focal="13" aperture="3.8" distance="10" k1="-0.8748" k2="0.3837" k3="-0.0372" />
<vignetting model="pa" focal="13" aperture="3.8" distance="1000" k1="-0.8748" k2="0.3837" k3="-0.0372" />
<vignetting model="pa" focal="13" aperture="5" distance="10" k1="-0.5207" k2="-0.0806" k3="0.1316" />
<vignetting model="pa" focal="13" aperture="5" distance="1000" k1="-0.5207" k2="-0.0806" k3="0.1316" />
<vignetting model="pa" focal="13" aperture="5.6" distance="10" k1="-0.6026" k2="0.2867" k3="-0.1180" />
<vignetting model="pa" focal="13" aperture="5.6" distance="1000" k1="-0.6026" k2="0.2867" k3="-0.1180" />
<vignetting model="pa" focal="13" aperture="7.1" distance="10" k1="-0.6500" k2="0.3972" k3="-0.1414" />
<vignetting model="pa" focal="13" aperture="7.1" distance="1000" k1="-0.6500" k2="0.3972" k3="-0.1414" />
<vignetting model="pa" focal="13" aperture="25" distance="10" k1="-0.6453" k2="0.3623" k3="-0.1133" />
<vignetting model="pa" focal="13" aperture="25" distance="1000" k1="-0.6453" k2="0.3623" k3="-0.1133" />
<vignetting model="pa" focal="16" aperture="4" distance="10" k1="-0.8350" k2="0.2741" k3="0.0331" />
<vignetting model="pa" focal="16" aperture="4" distance="1000" k1="-0.8350" k2="0.2741" k3="0.0331" />
<vignetting model="pa" focal="16" aperture="5" distance="10" k1="-0.4548" k2="-0.3554" k3="0.3268" />
<vignetting model="pa" focal="16" aperture="5" distance="1000" k1="-0.4548" k2="-0.3554" k3="0.3268" />
<vignetting model="pa" focal="16" aperture="6.3" distance="10" k1="-0.5034" k2="0.1695" k3="-0.0860" />
<vignetting model="pa" focal="16" aperture="6.3" distance="1000" k1="-0.5034" k2="0.1695" k3="-0.0860" />
<vignetting model="pa" focal="16" aperture="7.1" distance="10" k1="-0.5765" k2="0.3872" k3="-0.1987" />
<vignetting model="pa" focal="16" aperture="7.1" distance="1000" k1="-0.5765" k2="0.3872" k3="-0.1987" />
<vignetting model="pa" focal="16" aperture="25" distance="10" k1="-0.5564" k2="0.2517" k3="-0.0497" />
<vignetting model="pa" focal="16" aperture="25" distance="1000" k1="-0.5564" k2="0.2517" k3="-0.0497" />
<vignetting model="pa" focal="20" aperture="4.5" distance="10" k1="-0.9957" k2="0.6301" k3="-0.1733" />
<vignetting model="pa" focal="20" aperture="4.5" distance="1000" k1="-0.9957" k2="0.6301" k3="-0.1733" />
<vignetting model="pa" focal="20" aperture="5.6" distance="10" k1="-0.4075" k2="-0.4930" k3="0.4120" />
<vignetting model="pa" focal="20" aperture="5.6" distance="1000" k1="-0.4075" k2="-0.4930" k3="0.4120" />
<vignetting model="pa" focal="20" aperture="6.3" distance="10" k1="-0.3307" k2="-0.3853" k3="0.2640" />
<vignetting model="pa" focal="20" aperture="6.3" distance="1000" k1="-0.3307" k2="-0.3853" k3="0.2640" />
<vignetting model="pa" focal="20" aperture="7.1" distance="10" k1="-0.3795" k2="-0.1028" k3="0.0431" />
<vignetting model="pa" focal="20" aperture="7.1" distance="1000" k1="-0.3795" k2="-0.1028" k3="0.0431" />
<vignetting model="pa" focal="20" aperture="29" distance="10" k1="-0.3901" k2="0.0633" k3="0.0278" />
<vignetting model="pa" focal="20" aperture="29" distance="1000" k1="-0.3901" k2="0.0633" k3="0.0278" />
<vignetting model="pa" focal="24" aperture="4.5" distance="10" k1="-1.1988" k2="1.1534" k3="-0.4938" />
<vignetting model="pa" focal="24" aperture="4.5" distance="1000" k1="-1.1988" k2="1.1534" k3="-0.4938" />
<vignetting model="pa" focal="24" aperture="5.6" distance="10" k1="-0.4573" k2="-0.3947" k3="0.3748" />
<vignetting model="pa" focal="24" aperture="5.6" distance="1000" k1="-0.4573" k2="-0.3947" k3="0.3748" />
<vignetting model="pa" focal="24" aperture="6.3" distance="10" k1="-0.2715" k2="-0.5475" k3="0.3702" />
<vignetting model="pa" focal="24" aperture="6.3" distance="1000" k1="-0.2715" k2="-0.5475" k3="0.3702" />
<vignetting model="pa" focal="24" aperture="7.1" distance="10" k1="-0.1928" k2="-0.6044" k3="0.3684" />
<vignetting model="pa" focal="24" aperture="7.1" distance="1000" k1="-0.1928" k2="-0.6044" k3="0.3684" />
<vignetting model="pa" focal="24" aperture="29" distance="10" k1="-0.4338" k2="0.2285" k3="-0.0697" />
<vignetting model="pa" focal="24" aperture="29" distance="1000" k1="-0.4338" k2="0.2285" k3="-0.0697" />
</calibration>
</lens>

The crash happens for both 1.6.2 in Debian and a hand-compiled up-to-date Git version. GDB says:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff8ec4c700 (LWP 7242)]
memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:116
116 ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S: No such file or directory.
(gdb) bt full
#0 __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:116
No locals.
#1 0x00007ffff7a7426a in _default_process_tiling_ptp._omp_fn.2 () at /home/moy/local/usr/src/darktable/src/develop/tiling.c:755
j = 9223372035781033984
in_bpp = 16
ipitch = 0
ht = 18446744071562067968
wd = 18446744071562067968
ioffs = 0
ivoid = 0x7fff86051010
input = 0x7fff6e789040
#2 0x00007ffff2285716 in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
No symbol table info available.
#3 0x00007ffff42bb0a4 in start_thread (arg=0x7fff8ec4c700) at pthread_create.c:309
__res = <optimized out>
pd = 0x7fff8ec4c700
now = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140735588648704, 5775090013436797479, 1, 140737354125408, 140736548855008, 140735588648704, -5775268054840745433, -5775068742193749465}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = <optimized out>
pagesize_m1 = <optimized out>
sp = <optimized out>
freesize = <optimized out>
__PRETTY_FUNCTION
= "start_thread"
#4 0x00007ffff1fb4ccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals.
(gdb) info threads
Id Target Id Frame
31 Thread 0x7fff76d6d700 (LWP 7243) "darktable" __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:117
  • 30 Thread 0x7fff8ec4c700 (LWP 7242) "darktable" __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:116
    29 Thread 0x7fff8f44d700 (LWP 7241) "darktable" __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:118
    28 Thread 0x7fff50bb6700 (LWP 7240) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    27 Thread 0x7fff513b7700 (LWP 7239) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    26 Thread 0x7fff51bb8700 (LWP 7238) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    25 Thread 0x7fff9ee9d700 (LWP 7237) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    24 Thread 0x7fff9f69e700 (LWP 7236) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    23 Thread 0x7fff4f74c700 (LWP 7235) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    22 Thread 0x7fff9fe9f700 (LWP 7234) "darktable" 0x00007ffff1923c1c in __atan_avx (x=0.58908373286905891) at ../sysdeps/ieee754/dbl-64/s_atan.c:173
    21 Thread 0x7fffa3ccd700 (LWP 7233) "darktable" 0x00007ffff18cbfe5 in __ieee754_asin_sse2 (x=0.53494487302178995) at ../sysdeps/ieee754/dbl-64/e_asin.c:150
    20 Thread 0x7fffa2a6a700 (LWP 7232) "darktable" csloww2 (n=2, orig=-2.6919767580618568, dx=1.1442377452219667e-17, x=0.44961589552793646) at ../sysdeps/ieee754/dbl-64/s_sin.c:1213
    19 Thread 0x7fff95833700 (LWP 7228) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    18 Thread 0x7fff96034700 (LWP 7227) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    17 Thread 0x7fffa762f700 (LWP 7226) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    13 Thread 0x7fffaf415700 (LWP 7222) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    12 Thread 0x7fffc1dc7700 (LWP 7221) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    11 Thread 0x7fffc25c8700 (LWP 7220) "darktable" 0x00007ffff2287c9e in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
    10 Thread 0x7fffc3fff700 (LWP 7219) "gdbus" 0x00007ffff1fac18d in poll () at ../sysdeps/unix/syscall-template.S:81
    9 Thread 0x7fffe41c1700 (LWP 7218) "darktable" sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
    8 Thread 0x7fffe59c2700 (LWP 7217) "darktable" __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:117
    7 Thread 0x7fffe61c3700 (LWP 7216) "darktable" 0x00007ffff192a1a2 in __sin_avx (x=-0.84523754625226066) at ../sysdeps/ieee754/dbl-64/s_sin.c:316
    6 Thread 0x7fffe69c4700 (LWP 7215) "darktable" 0x00007ffff1f8653d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
    5 Thread 0x7fffe71c5700 (LWP 7214) "darktable" pthread_cond_wait@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
    4 Thread 0x7fffe79c6700 (LWP 7213) "darktable" pthread_cond_wait
    @GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
    3 Thread 0x7fffe81c7700 (LWP 7212) "darktable" pthread_cond_wait@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
    2 Thread 0x7fffe89c8700 (LWP 7211) "darktable" pthread_cond_wait
    @GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
    1 Thread 0x7ffff7fa5a40 (LWP 7207) "darktable" 0x00007ffff1fac18d in poll () at ../sysdeps/unix/syscall-template.S:81

Thanks,

Associated revisions

Revision e20f6f13 (diff)
Added by Roman Lebedev almost 5 years ago

Lens IOP: modify_roi_in(): do not request too much. Refs #10344

LensFun can return NAN coords, so we need to handle them carefully.

Revision 7e162aa2 (diff)
Added by Roman Lebedev almost 5 years ago

Lens IOP: process() do not even try to compute if coords are NAN/INF. Refs #10344

LensFun can return NAN coords, so we need to handle them carefully.

Revision a417578d
Added by Roman Lebedev almost 5 years ago

Merge pull request #875 from LebedevRI/iop-lens-fix-nan-coords

Lens IOP: properly handle NAN coords from LF. Fixes #10344

Revision 9f0a4379 (diff)
Added by Roman Lebedev almost 5 years ago

Lens IOP: modify_roi_in(): do not request too much. Refs #10344

LensFun can return NAN coords, so we need to handle them carefully.

(cherry picked from commit e20f6f1389ff28445255249ee8f051527cd99f1a)

Revision b6aa744c (diff)
Added by Roman Lebedev almost 5 years ago

Lens IOP: process() do not even try to compute if coords are NAN/INF. Refs #10344

LensFun can return NAN coords, so we need to handle them carefully.

(cherry picked from commit 7e162aa20e47efdae43e4a1fc7423fd604ee6e9f)

History

#1 Updated by Torsten Bronger almost 5 years ago

The problem is caused by Lensfun returning -NaN's in lens.c, line 866. This is the lf_modifier_apply_subpixel_geometry_distortion() call in modify_roi_in(). Regardless of whether Lensfun should return NaNs or not, I think DT should make the following check somewhere:

// x is the float coordinate from lensfun
if (0 <= x && x < image_width) {
    // round to int, lookup in bitmap, interpolate, ...
} else {
    // black pixel
}

This would cover the cases Inf, -Inf and ±NaN, and makes the typecast to int safe (`(int)1.6e16` is undefined in the C specs).

#2 Updated by Volker Lenhardt almost 5 years ago

  • Target version set to Candidate for next patch release

Maybe my experience with lens correction module has the same background:

openSUSE 13.2
KDE 4.14.5
DT 1.6.3-99.1.x86_64 from OBS multimedia_photo

Whenever I change one of the TCA parameters DT crashes. The same happens when a sidecar file is loaded containing TCA parameter changes.

Lens:
Canon EF-S 17-85mm f/4-5.6 IS USM
Canon EF 70-300mm f/4-5.6 IS USM

#3 Updated by Matthieu Moy almost 5 years ago

I don't think this is the same problem, as mine happens only in a very specific set of conditions.

You should probably open a new bug report. A reproducible recipe to get the crash (a RAW file and exact instruction to get the crash) and a debug trace would greatly help the developer. See http://www.darktable.org/development/.

(I'd rather let the developers choose the target version)

#4 Updated by Roman Lebedev almost 5 years ago

  • % Done changed from 0 to 20
  • Assignee set to Roman Lebedev
  • Status changed from New to Triaged

#5 Updated by Volker Lenhardt almost 5 years ago

Thank you, Matthieu, for your advice. It took me to the solution. My lensfun wasn't updated together with DT 1.6.3.

Lens correction now works for me.

#6 Updated by Roman Lebedev almost 5 years ago

  • % Done changed from 20 to 100
  • Status changed from Triaged to Fixed

Also available in: Atom PDF

Go to top