Summary: | Crash when closign digikam while filter active | ||
---|---|---|---|
Product: | [Applications] digikam | Reporter: | Johannes Wienke <languitar> |
Component: | Plugin-Editor-NoiseReduction | Assignee: | Digikam Developers <digikam-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | caulier.gilles |
Priority: | NOR | ||
Version: | 1.5.0 | ||
Target Milestone: | --- | ||
Platform: | Arch Linux | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 1.6.0 | |
Sentry Crash Report: |
Description
Johannes Wienke
2010-10-19 20:36:17 UTC
If you look into nrfilter.cpp, you will see that runningFlag() is called at right places. Sound like the filter is not triggered to be stopped from editor when editor is closed. Something probably need to fixed there : http://lxr.kde.org/source/extragear/graphics/digikam/utilities/imageeditor/editor/imagewindow.cpp#302 ... to check if computation is under progress... Note: can you check if it crash in a similar condition when QBM run with this filter ? Gilles Caulier I can reproduce the crash only with NR filter. I see that free allocation of buffer is the problem. I will fix it Gilles Caulier Marcel, Look the trace. It crash when memory allocation is cleanned at end of NR filter. If filter is canceled. memory allocation are there and must be cleaned. It the case if you cancel filter in editor using Cancel button on the bottom. Ther is no crash. If filter is under process, and if digiKam is closed, filter recieve a cancel notification. but in this case, memory allocation crash. Perhaps it's due to a race condition or a cancelization event sent at the wrong moment from thread manager class ? Gilles Caulier MArcel, I tried this patch : for (int c = 0; c < 3; c++) { if (d->fimg[c]) delete [] d->fimg[c]; } if (d->buffer[1]) delete [] d->buffer[1]; if (d->buffer[2]) delete [] d->buffer[2]; ...set at end of filterImage() NRFilter::method. It crash I moved this memory allocation code to destructor, just before to delete internal container : it crash. Gilles Caulier Marcel, Interresting. If memory cleanup is don in destructor, crash appear in another place : Thread 3 (Thread 0xa50dcb70 (LWP 23038)): [KCrash Handler] #6 0xb67a9182 in Digikam::NRFilter::waveletDenoise (this=0xc975450, fimg=0xcf1d9fc, width=3016, height=2008, threshold=2.1500001, softness=0.099999999999999978) at /mnt/data/Devel/SVN/trunk/graphics/digikam/libs/dimg/filters/nr/nrfilter.cpp:234 #7 0xb67a8aee in Digikam::NRFilter::filterImage (this=0xc975450) at /mnt/data/Devel/SVN/trunk/graphics/digikam/libs/dimg/filters/nr/nrfilter.cpp:137 #8 0xb6741abc in Digikam::DImgThreadedFilter::startFilterDirectly (this=0xc975450) at /mnt/data/Devel/SVN/trunk/graphics/digikam/libs/dimg/filters/dimgthreadedfilter.cpp:140 #9 0xb6741c98 in Digikam::DImgThreadedFilter::run (this=0xc975450) at /mnt/data/Devel/SVN/trunk/graphics/digikam/libs/dimg/filters/dimgthreadedfilter.cpp:161 #10 0xb68f6fed in Digikam::DynamicThread::DynamicThreadPriv::run (this=0xc944060) at /mnt/data/Devel/SVN/trunk/graphics/digikam/libs/threads/dynamicthread.cpp:240 #11 0xb497d762 in ?? () from /usr/lib/libQtCore.so.4 #12 0xb4987fcf in ?? () from /usr/lib/libQtCore.so.4 #13 0xb48f5ae5 in start_thread () from /lib/i686/libpthread.so.0 #14 0xb46c603e in clone () from /lib/i686/libc.so.6 Gilles Caulier I've had a similar crash recently. The reason is that one must remember that the derived class destructor is executed before the parent class destructor. So the crash happens like this: Thread is running, accessing NRFilterPriv data. Deleting the filter 1) ~NRFilter deletes NRFilterPriv 2) ~DImgThreadedFilter calls cancelFilter 3) cancelFilter wait()s for the thread to finish Between 1) and 2) the thread is still running and accessed the deleted data. Solution: Call cancelFilter in ~NRFilter before any data is deleted. Marcel, This problem occur only with NR filter which has a d private internal container, or also another filter, as BCG or LensFun tool ? I tried to reproduce this problem with these filters, and all work fine. This is relevant of part of image data stored in NR filter d private container ? Gilles SVN commit 1188075 by cgilles: I confirm. Calling cancelFilter() in NR filter destructor fix crash. CCBUGS: 254679 M +3 -0 nrfilter.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1188075 Marcel, I can reproduce the crash with Restoration tool, in same conditions : Thread 4 (Thread 0x9d733b70 (LWP 11689)): [KCrash Handler] #6 0xb68005fb in cimg_library::CImg<float>::_atXYZV(int, int, int, int) const () from /usr/lib/libdigikamcore.so.1 #7 0xb680c419 in cimg_library::CImg<float>::get_crop(int, int, int, int, int, int, int, int, bool) const () from /usr/lib/libdigikamcore.so.1 #8 0xb67fd9ce in cimg_library::CImg<float>::get_crop(int, int, int, int, bool) const () from /usr/lib/libdigikamcore.so.1 #9 0xb67c36c8 in cimg_library::CImg<float>::greycstoration_thread(void*) () from /usr/lib/libdigikamcore.so.1 #10 0xb48c9ae5 in start_thread () from /lib/i686/libpthread.so.0 #11 0xb469a03e in clone () from /lib/i686/libc.so.6 Probably a general fix must be done in all filter to prevent this problem... Gilles This cannot be generally solved in the parent class because the derived class destructor is called first, and virtual methods cannot be called from a destructor. To be safe, any filter which has private data accessed from the thread should call cancelFilter in its destructor first. I dont see a better solution that is safe everywhere. Ok, i will fix it... Another problem now, depending only of CImg based tools, as Restoration. If i patch descructor to call cancelFilter(), it do not crash, but thread still to run in memory. If i don't patch, digiKam crash. Note : if destructor is not patched but if i press cancel button during Cimg computations all is fine. I cannot see where is the difference. Can you reproduce the problem ? CImg threads are a little bit complicated to manage. Gilles SVN commit 1189681 by cgilles: CImg filter : call cancelFilter() in destructor CCBUGS: 254679 M +1 -0 greycstorationfilter.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1189681 SVN commit 1189909 by cgilles: call cancelFilter in filter destructors. BUGS: 254679 M +1 -0 imageplugins/enhance/hotpixels/hotpixelfixer.cpp M +4 -1 imageplugins/transform/resizetool.cpp M +1 -0 libs/dimg/filters/auto/autolevelsfilter.cpp M +1 -0 libs/dimg/filters/auto/normalizefilter.cpp M +1 -0 libs/dimg/filters/auto/stretchfilter.cpp M +1 -0 libs/dimg/filters/bcg/bcgfilter.cpp M +1 -0 libs/dimg/filters/bw/bwsepiafilter.cpp M +5 -0 libs/dimg/filters/bw/infraredfilter.cpp M +1 -1 libs/dimg/filters/bw/infraredfilter.h M +1 -0 libs/dimg/filters/bw/mixerfilter.cpp M +1 -0 libs/dimg/filters/bw/tonalityfilter.cpp M +1 -0 libs/dimg/filters/cb/cbfilter.cpp M +1 -0 libs/dimg/filters/curves/curvesfilter.cpp M +1 -0 libs/dimg/filters/decorate/borderfilter.cpp M +10 -3 libs/dimg/filters/decorate/texturefilter.cpp M +1 -2 libs/dimg/filters/decorate/texturefilter.h M +5 -0 libs/dimg/filters/fx/blurfilter.cpp M +1 -1 libs/dimg/filters/fx/blurfilter.h M +5 -0 libs/dimg/filters/fx/charcoalfilter.cpp M +1 -1 libs/dimg/filters/fx/charcoalfilter.h M +5 -0 libs/dimg/filters/fx/distortionfxfilter.cpp M +1 -1 libs/dimg/filters/fx/distortionfxfilter.h M +5 -0 libs/dimg/filters/fx/embossfilter.cpp M +1 -1 libs/dimg/filters/fx/embossfilter.h M +1 -0 libs/dimg/filters/fx/filmgrainfilter.cpp M +5 -0 libs/dimg/filters/fx/invertfilter.cpp M +1 -1 libs/dimg/filters/fx/invertfilter.h M +5 -0 libs/dimg/filters/fx/oilpaintfilter.cpp M +1 -1 libs/dimg/filters/fx/oilpaintfilter.h M +5 -0 libs/dimg/filters/fx/raindropfilter.cpp M +1 -1 libs/dimg/filters/fx/raindropfilter.h M +1 -0 libs/dimg/filters/hsl/hslfilter.cpp M +6 -1 libs/dimg/filters/icc/icctransformfilter.cpp M +2 -1 libs/dimg/filters/icc/icctransformfilter.h M +1 -0 libs/dimg/filters/lc/localcontrastfilter.cpp M +4 -2 libs/dimg/filters/lens/antivignettingfilter.cpp M +1 -1 libs/dimg/filters/lens/antivignettingfilter.h M +5 -0 libs/dimg/filters/lens/lensdistortionfilter.cpp M +1 -1 libs/dimg/filters/lens/lensdistortionfilter.h M +1 -0 libs/dimg/filters/lens/lensfunfilter.cpp M +1 -0 libs/dimg/filters/levels/levelsfilter.cpp M +0 -2 libs/dimg/filters/nr/nrfilter.cpp M +5 -0 libs/dimg/filters/sharp/sharpenfilter.cpp M +1 -1 libs/dimg/filters/sharp/sharpenfilter.h M +5 -0 libs/dimg/filters/sharp/unsharpmaskfilter.cpp M +1 -1 libs/dimg/filters/sharp/unsharpmaskfilter.h M +2 -1 libs/dimg/filters/transform/contentawarefilter.cpp M +1 -0 libs/dimg/filters/transform/freerotationfilter.cpp M +5 -0 libs/dimg/filters/transform/shearfilter.cpp M +1 -1 libs/dimg/filters/transform/shearfilter.h M +1 -0 libs/dimg/filters/wb/wbfilter.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1189909 |