Project

General

Profile

Bug #8829

Segfault with OpenCL and lensfun

Added by Gabriel Ebner over 7 years ago.

Status:
Fixed
Priority:
Medium
Category:
Darkroom
Start date:
07/19/2012
Due date:
% Done:

100%

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

Description

With OpenCL enabled, darktable segfaults immediately after enabling the lens correction plugin. Sample RAW.

I'm running the current git version. darktable --disable-opencl works fine. git bisect identifies the opencl: added support for lens module commit as culprit.

Backtrace and output of darktable -d opencl are attached.

Hardware is a Radeon HD 6950 with Catalyst 12.6 drivers, running under Ubuntu precise (64-bit).

gdb.txt (53.6 KB) gdb.txt Gabriel Ebner, 07/19/2012 09:09 PM
stdout.txt (9.95 KB) stdout.txt Gabriel Ebner, 07/19/2012 09:09 PM
gdb.txt (53.6 KB) gdb.txt Backtrace with current version Gabriel Ebner, 07/21/2012 11:40 AM
debug.txt (10.3 KB) debug.txt Output of darktable -d opencl -d perf Gabriel Ebner, 07/21/2012 11:55 AM
without-lens-correction.txt (12.6 KB) without-lens-correction.txt Output darktable -d opencl -d perf without lens correction Gabriel Ebner, 07/21/2012 12:26 PM
mil-panasonic.xml (5.54 KB) mil-panasonic.xml Gabriel Ebner, 07/21/2012 12:26 PM

History

#1 Updated by Simon Spannagel over 7 years ago

  • Target version set to Candidate for next patch release
  • Category set to Darkroom

#2 Updated by Simon Spannagel over 7 years ago

added Ulrich to the watcher list.

#3 Updated by Ulrich Pegelow over 7 years ago

  • % Done changed from 0 to 10
  • Assignee set to Ulrich Pegelow
  • Status changed from New to Confirmed

Confirmed here with Nvidia GSX450 and latest OpenCL driver

#4 Updated by Ulrich Pegelow over 7 years ago

Update: with the raw file submitted, DT also crashes when OpenCL is not activated at all. Problem seems not be be OpenCL related and needs further investigation.

#5 Updated by Ulrich Pegelow over 7 years ago

Here DT crashes in cpu path when calling dt_interpolation_compute_sample() in lens.c:262.

Added Edouard to the watch list.

#6 Updated by Ulrich Pegelow over 7 years ago

  • % Done changed from 10 to 50
  • Status changed from Confirmed to In Progress

I pushed a few patches to git master which hopefully prevent DT from crashing in lens correction.

However, with the image provided by Gabriel I get black output. Background is that lensfun knows the lens but not the camera. In that case DT tries to get the crop factor from exif data, or - failing that - setting it to 1. What I found instead, is that DT sets crop factor to zero in all cases.

#7 Updated by Ulrich Pegelow over 7 years ago

I just pushed another patch to git master. At least for newly imported images this should now correctly deal with the case where lens is known to lensfun but camera not.

@Gabriel: Please check and report back if this solves your problem.

Side remark: lens correction lacks a clear feedback to user if camera/lens are found in lensfun database and if lens correction is applied.

#8 Updated by Gabriel Ebner over 7 years ago

@Gabriel: Please check and report back if this solves your problem.

Even with your latest commit (36fa24da), I still get a segfault. As before, this only happens with OpenCL enabled, darktable --disable-opencl works fine.

#9 Updated by Ulrich Pegelow over 7 years ago

Could you please run DT with '-d opencl -d perf'. Maybe this sheds some further light on the topic.

#10 Updated by Gabriel Ebner over 7 years ago

#11 Updated by Ulrich Pegelow over 7 years ago

Hmm, we not even reach the point where DT would normally tell us something about the OpenCL kernels and their timings.
I assume you can run other OpenCL modules without problems? Can you please make an example with some modules but without lens (once again -d opencl -d perf).

One further thing to check: is there any dependency on interpolation mode (bilinear, bicubic, ...) which you can set in preferences?

#12 Updated by Ulrich Pegelow over 7 years ago

BTW which version of lensfun do you use?

#13 Updated by Gabriel Ebner over 7 years ago

Everything works fine without lens correction; debugging output with lens correction disabled is attached.

There is no dependency on the interpolation mode, debugging output is the same, backtrace too.

I'm using the current svn version of liblensfun, patched to support the GX1... which explains why you can't reproduce it. I've attached my version of mil-panasonic.xml.

#14 Updated by Ulrich Pegelow over 7 years ago

OK, might be that the new version of lensfun has triggered some incompatibility. Currently DT has issues to properly detect lensfun 0.26 on my system during build time. As soon as this is fixed, I dig deeper into it.

#15 Updated by Ulrich Pegelow over 7 years ago

Even after installing lensfun 0.26 and your patched mil-panasonic.xml file I am not able to reproduce the crash. Everything runs absolutely smooth here.

So you are a bit on your own with this problem. Maybe it helps if you start with a complete re-install of darktable. So remove all installation files of DT from your disk, do a 'rm ./build', and then build and install DT anew.

#16 Updated by Gabriel Ebner over 7 years ago

  • % Done changed from 50 to 70
  • Status changed from In Progress to Patch attached

The memory transfers from the temporary buffer in process_cl were marked non-blocking, and the fglrx opencl runtime decided to read the buffer after the temporary buffer was already freed, triggering a segfault. Apparently the nvidia opencl runtime disregards the non-blocking flag and just reads the buffer immediately, thereby not triggering this bug.
I just had to change the memory transfers from non-blocking to blocking and the segfault was gone.

I have filed a pull request on github: https://github.com/darktable-org/darktable/pull/26

#17 Updated by Ulrich Pegelow over 7 years ago

Cool! We might lose a little bit of efficiency but if it improves stability, let's go for it. I will check in more detail tomorrow.

#18 Updated by Ulrich Pegelow over 7 years ago

  • % Done changed from 70 to 100
  • Status changed from Patch attached to Fixed

Fixed with Gabriel's pull request.

The good thing is: we not only fixed this bug but solved at least three other issues in lens correction on the way :)

Also available in: Atom PDF

Go to top