Bug 411917

Summary: Filter brush with Color Adjustment freezes Krita
Product: [Applications] krita Reporter: M <manuel.snudl.zeidler>
Component: Brush enginesAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: dimula73, griffinvalley, halla, tamtamy.tymona
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: gdb backtrace
Backtrace from debug build

Description M 2019-09-14 16:51:29 UTC
Created attachment 122655 [details]
gdb backtrace

SUMMARY
A Filter engine brush set to use Color Adjustment curves causes Krita to freeze, if the document uses LAB or XYZ color spaces.

STEPS TO REPRODUCE
1. Create a document in LAB or XYZ color space
2. Open the brush settings and choose a Filter brush preset
3. Change the filter it uses to Color Adjustment (curves)
4. Attempt to modify the curve of any channel

OBSERVED RESULT
Krita freezes entirely.

EXPECTED RESULT
The adjustments work normally on the brush like with RGB documents.

SOFTWARE/OS VERSIONS
Tested in 4.2.6 from distro repository and master (git cb4306b) with the same outcome.

ADDITIONAL INFORMATION
RGB or CMYK don't seem to cause this issue.
Comment 1 wolthera 2019-09-21 14:56:12 UTC
This doesn't seem to happen in current master. M, could you check whether this still happens with the latest nightly(Krita: Next)? We had some freezes in the brush settings dialog that got fixed recently, maybe this is related...
Comment 2 M 2019-09-21 17:36:04 UTC
That's strange, it still happens on my system with master (git 59d8e62) and the newest Next AppImage (git a76f4c3). I checked multiple times, it was reproducible every try.
Comment 3 wolthera 2019-09-21 17:38:55 UTC
Hm... I'd suggest you to run Krita in GDB, but the problem is that the freeze happens in the brush editor, and that will make it impossible to switch to the terminal to do some debugging. Does anything interesting happen in the terminal when you run your own compiled Krita and make this freeze happen?
Comment 4 M 2019-09-21 18:22:33 UTC
For the GDB backtrace above I had use DISPLAY=:0 gdb krita (thanks to Dmitry for trick) from a virtual terminal, otherwise the whole session would stay frozen, correct. Same output from the build directory executable. What debugging could I do then?
Comment 5 wolthera 2019-09-21 18:32:38 UTC
Ah, I hadn't noticed the backtrace somehow!

Hm... what is a little weird about that backtrace is that there seem to be debug symbols missing, which is what causes all the ??? here:

---------------------------
Thread 33 (Thread 0x7fffa9ffa700 (LWP 4040)):
#0  0x00007fffe6ea36b0 in ?? () from /usr/lib/liblcms2.so.2
#1  0x00007fffe54fd0bf in ?? () from /usr/lib/kritaplugins/kritalcmsengine.so
#2  0x00007fffe5f81f29 in ?? () from /usr/lib/kritaplugins/kritacolorsfilters.so
#3  0x00007ffff5eae7f8 in KisColorTransformationConfiguration::colorTransformation(KoColorSpace const*, KisColorTransformationFilter const*) const () from /usr/lib/libkritaimage.so.18
#4  0x00007ffff5eb07ad in KisColorTransformationFilter::processImpl(KisSharedPtr<KisPaintDevice>, QRect const&, KisPinnedSharedPtr<KisFilterConfiguration>, KoUpdater*) const () from /usr/lib/libkritaimage.so.18
#5  0x00007ffff5ead299 in KisFilter::process(KisSharedPtr<KisPaintDevice>, KisSharedPtr<KisPaintDevice>, KisSharedPtr<KisSelection>, QRect const&, KisPinnedSharedPtr<KisFilterConfiguration>, KoUpdater*) const () from /usr/lib/libkritaimage.so.18
#6  0x00007ffff5ead599 in KisFilter::process(KisSharedPtr<KisPaintDevice>, QRect const&, KisPinnedSharedPtr<KisFilterConfiguration>, KoUpdater*) const () from /usr/lib/libkritaimage.so.18
#7  0x00007fffe4daf26b in ?? () from /usr/lib/kritaplugins/kritafilterop.so
#8  0x00007ffff5e8237c in ?? () from /usr/lib/libkritaimage.so.18
#9  0x00007ffff5e8148a in ?? () from /usr/lib/libkritaimage.so.18
#10 0x00007ffff5e815cb in ?? () from /usr/lib/libkritaimage.so.18
#11 0x00007ffff5e815cb in ?? () from /usr/lib/libkritaimage.so.18
#12 0x00007ffff5e815cb in ?? () from /usr/lib/libkritaimage.so.18
#13 0x00007ffff5e815cb in ?? () from /usr/lib/libkritaimage.so.18
#14 0x00007ffff5e8165a in KisPaintOp::paintBezierCurve(KisPaintInformation const&, QPointF const&, QPointF const&, KisPaintInformation const&, KisDistanceInformation*) () from /usr/lib/libkritaimage.so.18
#15 0x00007ffff6f7d358 in KisMaskedFreehandStrokePainter::paintBezierCurve(KisPaintInformation const&, QPointF const&, QPointF const&, KisPaintInformation const&) () from /usr/lib/libkritaui.so.18
#16 0x00007ffff6f77936 in FreehandStrokeStrategy::doStrokeCallback(KisStrokeJobData*) () from /usr/lib/libkritaui.so.18
#17 0x00007ffff5e3624f in ?? () from /usr/lib/libkritaimage.so.18
#18 0x00007ffff49fc9a2 in ?? () from /usr/lib/libQt5Core.so.5
#19 0x00007ffff49f95b0 in ?? () from /usr/lib/libQt5Core.so.5
#20 0x00007ffff277457f in start_thread () from /usr/lib/libpthread.so.0
#21 0x00007ffff466e0e3 in clone () from /usr/lib/libc.so.6
------------------------------
It would've been nice to see what is going on in kritalcmsengine, for example, that causes this crash...

You don't happen to know why there's debug symbols missing, do you?
Comment 6 M 2019-09-21 19:10:40 UTC
Created attachment 122790 [details]
Backtrace from debug build

My mistake, that was a backtrace from the distro package. Here's the output from the actual build with CMAKE_BUILD_TYPE Debug and KRITA_DEVS on. Had to figure out why logging didn't work before.
Comment 7 wolthera 2019-09-21 19:38:20 UTC
Ah, fantastic. I still cannot reproduce, but now we have a backtrace, we can try to figure out what is going on at the very least.

-------------------------------------------------------------------------------
Thread 31 (Thread 0x7fffc0f87700 (LWP 7381)):
#0  0x00007fffec4426b0 in ?? () from /usr/lib/liblcms2.so.2
#1  0x00007fffe51d8fed in LcmsColorSpace<KoBgrU8Traits>::createPerChannelAdjustment (this=0x555559abe5a0, transferValues=0x7fffa40e47c0) at /home/snu/Applications/kritadev/krita/plugins/color/lcms2engine/LcmsColorSpace.h:330
#2  0x00007fffe5e46a61 in KisPerChannelFilter::createTransformation (this=<optimized out>, cs=0x555559abe5a0, config=...) at /home/snu/Applications/kritadev/krita/plugins/filters/colorsfilters/kis_perchannel_filter.cpp:306
#3  0x00007ffff5b13bb6 in KisColorTransformationConfiguration::colorTransformation (this=this@entry=0x7fffa401bf50, cs=cs@entry=0x555559abe5a0, filter=filter@entry=0x55555888df30) at /usr/include/c++/9.1.0/bits/atomic_base.h:318
#4  0x00007ffff5b17528 in KisColorTransformationFilter::processImpl (this=0x55555888df30, device=..., applyRect=..., config=..., progressUpdater=0x7fffa408fcf0) at /home/snu/Applications/kritadev/krita/libs/global/kis_shared_ptr.h:179
#5  0x00007ffff5b115ec in KisFilter::process (this=0x55555888df30, src=..., dst=..., selection=..., applyRect=..., config=..., progressUpdater=0x7fffa408fcf0) at /usr/include/c++/9.1.0/bits/atomic_base.h:318
#6  0x00007ffff5b125a7 in KisFilter::process (this=<optimized out>, device=..., applyRect=..., config=..., progressUpdater=progressUpdater@entry=0x0) at /usr/include/c++/9.1.0/bits/atomic_base.h:318
#7  0x00007fffe4843fd5 in KisFilterOp::paintAt (this=0x7fffa4094530, info=...) at /home/snu/Applications/kritadev/krita/libs/global/kis_shared_ptr.h:218
#8  0x00007ffff5abaf38 in KisPaintInformation::paintAt<KisPaintOp> (distanceInfo=0x5555e01c6f70, op=..., this=0x7fffc0f86670) at /home/snu/Applications/kritadev/krita/libs/image/kis_timing_information.h:24
#9  KisPaintOpUtils::paintLine<KisPaintOp> (op=..., pi1=..., pi2=..., currentDistance=currentDistance@entry=0x5555e01c6f70, fanCornersEnabled=false, fanCornersStep=1) at /home/snu/Applications/kritadev/krita/libs/image/brushengine/kis_paintop_utils.h:96
#10 0x00007ffff5aba7d0 in KisPaintOp::paintLine (currentDistance=0x5555e01c6f70, pi2=..., pi1=..., this=0x7fffa4094530) at /home/snu/Applications/kritadev/krita/libs/image/brushengine/kis_paintop.cc:156
#11 paintBezierCurve (paintOp=0x7fffa4094530, pi1=..., control1=..., control2=..., pi2=..., currentDistance=0x5555e01c6f70) at /home/snu/Applications/kritadev/krita/libs/image/brushengine/kis_paintop.cc:125
#12 0x00007ffff5aba8e4 in paintBezierCurve (paintOp=0x7fffa4094530, pi1=..., control1=..., control2=..., pi2=..., currentDistance=0x5555e01c6f70) at /home/snu/Applications/kritadev/krita/libs/image/brushengine/kis_paintop.cc:137
#13 0x00007ffff5aba8e4 in paintBezierCurve (paintOp=0x7fffa4094530, pi1=..., control1=..., control2=..., pi2=..., currentDistance=0x5555e01c6f70) at /home/snu/Applications/kritadev/krita/libs/image/brushengine/kis_paintop.cc:137
#14 0x00007ffff5aba8e4 in paintBezierCurve (paintOp=0x7fffa4094530, pi1=..., control1=..., control2=..., pi2=..., currentDistance=0x5555e01c6f70) at /home/snu/Applications/kritadev/krita/libs/image/brushengine/kis_paintop.cc:137
#15 0x00007ffff5aba8e4 in paintBezierCurve (paintOp=0x7fffa4094530, pi1=..., control1=..., control2=..., pi2=..., currentDistance=0x5555e01c6f70) at /home/snu/Applications/kritadev/krita/libs/image/brushengine/kis_paintop.cc:137
#16 0x00007ffff5aba964 in KisPaintOp::paintBezierCurve (this=<optimized out>, pi1=..., control1=..., control2=..., pi2=..., currentDistance=<optimized out>) at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:901
#17 0x00007ffff6ef9ce7 in KisMaskedFreehandStrokePainter::<lambda(KisFreehandStrokeInfo*)>::operator() (data=<optimized out>, data=<optimized out>, __closure=<synthetic pointer>) at /home/snu/Applications/kritadev/krita/libs/ui/tool/strokes/KisMaskedFreehandStrokePainter.cpp:67
#18 KisMaskedFreehandStrokePainter::applyToAllPainters<KisMaskedFreehandStrokePainter::paintBezierCurve(const KisPaintInformation&, const QPointF&, const QPointF&, const KisPaintInformation&)::<lambda(KisFreehandStrokeInfo*)> > (this=0x7fffa40df940, this@entry=0x5555e0f13d08, this=0x7fffa40df940, this@entry=0x5555e0f13d08, func=...) at /home/snu/Applications/kritadev/krita/libs/ui/tool/strokes/KisMaskedFreehandStrokePainter.cpp:43
#19 KisMaskedFreehandStrokePainter::paintBezierCurve (this=this@entry=0x7fffa40df940, pi1=..., control1=..., control2=..., pi2=...) at /home/snu/Applications/kritadev/krita/libs/ui/tool/strokes/KisMaskedFreehandStrokePainter.cpp:66
#20 0x00007ffff6eed578 in FreehandStrokeStrategy::doStrokeCallback (this=0x5555e0f36920, data=<optimized out>) at /home/snu/Applications/kritadev/krita/libs/ui/tool/strokes/freehand_stroke.cpp:181
#21 0x00007ffff5a61152 in KisStrokeJob::run (this=<optimized out>) at /home/snu/Applications/kritadev/build/libs/image/kritaimage_autogen/EWIEGA46WW/../../../../../krita/libs/image/kis_stroke_job.h:44
#22 KisUpdateJobItem::run (this=0x5555d4645080) at /home/snu/Applications/kritadev/build/libs/image/kritaimage_autogen/EWIEGA46WW/../../../../../krita/libs/image/kis_update_job_item.h:91
#23 0x00007ffff2a2f9a2 in ?? () from /usr/lib/libQt5Core.so.5
#24 0x00007ffff2a2c5b0 in ?? () from /usr/lib/libQt5Core.so.5
#25 0x00007ffff1cac57f in start_thread () from /usr/lib/libpthread.so.0
#26 0x00007ffff25590e3 in clone () from /usr/lib/libc.so.6
Comment 8 Tiar 2019-09-21 19:47:52 UTC
I think I know what the issue is, or at least, Dmitry for sure knows, so let's set it assigned to me...
Comment 9 Halla Rempt 2019-09-28 08:48:13 UTC
But what is it that you think it is :P
Comment 10 Halla Rempt 2021-09-07 11:24:25 UTC
This still crashes, but no progress since 2019, so I'm resetting to confirmed.
Comment 11 wolthera 2021-09-19 16:10:11 UTC
Halla, can you attach a new backtrace? Because I still cannot reproduce this bug, and the backtrace is outdated (the line numbers don't match the function).
Comment 12 wolthera 2021-09-27 15:44:39 UTC
Git commit 8218dcd6cd6b40e4da31d2f6f179c597c3c1a9be by Wolthera van Hövell tot Westerflier.
Committed on 27/09/2021 at 15:40.
Pushed by woltherav into branch 'krita/5.0'.

Ensure the amount of curves passed for per channel is not too low.

It seems we may have had a period where too few curves were stored
in the config. This commit appends identity curves for the missing
entries, avoiding crashes.
Related: bug 428349

M  +9    -1    plugins/filters/colorsfilters/kis_perchannel_filter.cpp

https://invent.kde.org/graphics/krita/commit/8218dcd6cd6b40e4da31d2f6f179c597c3c1a9be
Comment 13 wolthera 2021-09-27 15:45:11 UTC
Git commit 2a5cf5d3458aed467c2683947403edc2ce06aa5b by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 27/09/2021 at 15:44.
Pushed by woltherav into branch 'master'.

Ensure the amount of curves passed for per channel is not too low.

It seems we may have had a period where too few curves were stored
in the config. This commit appends identity curves for the missing
entries, avoiding crashes.
Related: bug 428349


(cherry picked from commit 8218dcd6cd6b40e4da31d2f6f179c597c3c1a9be)

M  +9    -1    plugins/filters/colorsfilters/kis_perchannel_filter.cpp

https://invent.kde.org/graphics/krita/commit/2a5cf5d3458aed467c2683947403edc2ce06aa5b
Comment 14 wolthera 2021-09-27 15:46:58 UTC
I think my other fix fixes this bug as well, but I cannot check as I cannot reproduce the original bug to begin with...
Comment 15 Dmitry Kazakov 2021-12-17 07:14:45 UTC
The bug seems to be fixed. Here are the steps to reproduce that:

1) Create an RGB image
2) Add a transparence mask and activate it
3) Select filter brush, choose Color Adjustment filter. Make sure that there are only two color curves, Gray and Alpha.
4) Select the parent layer (which is RGB)
5) Try to paint. It shouldn't crash.