Bug 441358

Summary: smudge brush with "overlay mode" checked crashes when painting on a filter layer
Product: [Applications] krita Reporter: thetwo <thetwo222>
Component: Filter LayersAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: halla, tamtamy.tymona
Priority: NOR Keywords: regression, release_blocker
Version First Reported In: 5.0.0-beta1   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: kritacrash
overlay mode

Description thetwo 2021-08-22 12:45:02 UTC
SUMMARY


STEPS TO REPRODUCE
1.Create a new filter layer or filter mask
2.Switch "color smudge engine" and turn on "overlay mode"
3.Paint on the filter layer or mask
Comment 1 Halla Rempt 2021-08-23 09:25:52 UTC
Hi,

I cannot reproduce this. Which filter are you using? And is it the layer or mask or the brush blending mode you switched to Overlay?

And could you check whether there's a kritacrash.log in %APPDATA% and if so, attach it?
Comment 2 thetwo 2021-08-23 11:18:42 UTC
Created attachment 140974 [details]
kritacrash
Comment 3 thetwo 2021-08-23 11:19:04 UTC
(In reply to Halla Rempt from comment #1)
> 嗨,
> 
> 我无法重现这一点。你用的是哪个过滤器?是图层或蒙版还是您切换到叠加的画笔混合模式?
> 
> 您能否检查 %APPDATA% 中是否有 kritacrash.log,如果有,请附上它?

All filters will crash.
Not blending mode. Is F5-GENERAL-overly mode
Comment 4 thetwo 2021-08-23 11:22:52 UTC
Created attachment 140975 [details]
overlay mode
Comment 5 Halla Rempt 2021-08-23 12:33:21 UTC
Thanks for the information! Now I get it. I guess we're using "overlay" a bit too much in Krita. I have reproduced the crash.
Comment 6 Halla Rempt 2021-08-23 12:35:34 UTC
Backtrace:

[Switching to Thread 0x7fff877fe700 (LWP 154607)]
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:356
356     ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) bt
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:356
#1  0x00007ffff6be23ca in KisTiledDataManager::readBytesBody (this=0x7fff7403a4a0, 
    data=0x7fff74097e10 '\377' <repeats 176 times>, "p(\264(\364(8)x)\270)\370)7*t*\264*\360*0+"..., x=810, 
    y=1088, width=60, height=60, dataRowStride=480)
    at /home/halla/dev/krita/libs/image/tiles3/kis_tiled_data_manager_p.h:128
#2  0x00007ffff6be5750 in KisTiledDataManager::readBytes (this=0x7fff7403a4a0, 
    data=0x7fff74097e10 '\377' <repeats 176 times>, "p(\264(\364(8)x)\270)\370)7*t*\264*\360*0+"..., x=810, 
    y=1088, width=60, height=60, dataRowStride=-1)
    at /home/halla/dev/krita/libs/image/tiles3/kis_tiled_data_manager.cc:701
#3  0x00007ffff6f5a248 in KisDataManager::readBytes (this=0x7fff7403a4a0, 
    data=0x7fff74097e10 '\377' <repeats 176 times>, "p(\264(\364(8)x)\270)\370)7*t*\264*\360*0+"..., x=810, 
    y=1088, w=60, h=60, dataRowStride=-1) at /home/halla/dev/krita/libs/image/kis_datamanager.h:254
#4  0x00007ffff6f62922 in KisPaintDevice::Private::KisPaintDeviceStrategy::readBytesImpl (this=0x7fff740365c0, 
    data=0x7fff74097e10 '\377' <repeats 176 times>, "p(\264(\364(8)x)\270)\370)7*t*\264*\360*0+"..., rect=..., 
    dataRowStride=-1) at /home/halla/dev/krita/libs/image/kis_paint_device_strategies.h:152
#5  0x00007ffff6f625a7 in KisPaintDevice::Private::KisPaintDeviceStrategy::readBytes (this=0x7fff740365c0, 
    data=0x7fff74097e10 '\377' <repeats 176 times>, "p(\264(\364(8)x)\270)\370)7*t*\264*\360*0+"..., rect=...)
    at /home/halla/dev/krita/libs/image/kis_paint_device_strategies.h:135
#6  0x00007ffff6f57908 in KisPaintDevice::readBytes (this=0x7fff74027730, 
    data=0x7fff74097e10 '\377' <repeats 176 times>, "p(\264(\364(8)x)\270)\370)7*t*\264*\360*0+"..., rect=...)
    at /home/halla/dev/krita/libs/image/kis_paint_device.cc:2010
#7  0x00007fffd1ed6da6 in KisColorSmudgeSourceImage::readBytes (this=0x7fff7403cd30, 
    dstPtr=0x7fff74097e10 '\377' <repeats 176 times>, "p(\264(\364(8)x)\270)\370)7*t*\264*\360*0+"..., rect=...)
    at /home/halla/dev/krita/plugins/paintops/colorsmudge/KisColorSmudgeSource.cpp:58
#8  0x00007fffd1ed8e7d in KisColorSmudgeStrategyBase::blendInBackgroundWithSmearing (this=0x7fff74020960, 
    dst=..., src=..., srcRect=..., dstRect=..., smudgeRateOpacity=255 '\377')
    at /home/halla/dev/krita/plugins/paintops/colorsmudge/KisColorSmudgeStrategyBase.cpp:269
#9  0x00007fffd1ed8674 in KisColorSmudgeStrategyBase::blendBrush (this=0x7fff74020960, dstPainters=..., 
    srcSampleDevice=..., maskDab=..., preserveMaskDab=true, srcRect=..., dstRect=..., currentPaintColor=..., 
    opacity=0.93449799999999994, smudgeRateValue=0.59999999999999998, 
    maxPossibleSmudgeRateValue=0.59999999999999998, colorRateValue=0, smudgeRadiusValue=0)
    at /home/halla/dev/krita/plugins/paintops/colorsmudge/KisColorSmudgeStrategyBase.cpp:232
#10 0x00007fffd1ee57d3 in KisColorSmudgeStrategyWithOverlay::paintDab (this=0x7fff74020960, srcRect=..., 
    dstRect=..., currentPaintColor=..., opacity=0.93449799999999994, colorRateValue=0, 
    smudgeRateValue=0.59999999999999998, maxPossibleSmudgeRateValue=0.59999999999999998, 
    lightnessStrengthValue=1, smudgeRadiusValue=0)
    at /home/halla/dev/krita/plugins/paintops/colorsmudge/KisColorSmudgeStrategyWithOverlay.cpp:95
#11 0x00007fffd1ebfcda in KisColorSmudgeOp::paintAt (this=0x7fff7404c3b0, info=...)
    at /home/halla/dev/krita/plugins/paintops/colorsmudge/kis_colorsmudgeop.cpp:252
#12 0x00007ffff6c4e8be in KisPaintInformation::paintAt<KisPaintOp> (this=0x7fff877fd940, op=..., 
    distanceInfo=0x55555f603a40) at /home/halla/dev/krita/libs/image/brushengine/kis_paint_information.h:105
#13 0x00007ffff6c4e772 in KisPaintOpUtils::paintLine<KisPaintOp> (op=..., pi1=..., pi2=..., 
    currentDistance=0x55555f603a40, fanCornersEnabled=false, fanCornersStep=1)
    at /home/halla/dev/krita/libs/image/brushengine/kis_paintop_utils.h:84
#14 0x00007ffff6c4c667 in KisPaintOp::paintLine (this=0x7fff7404c3b0, pi1=..., pi2=..., 
    currentDistance=0x55555f603a40) at /home/halla/dev/krita/libs/image/brushengine/kis_paintop.cc:144
#15 0x00007ffff6c4c1ce in paintBezierCurve (paintOp=0x7fff7404c3b0, pi1=..., control1=..., control2=..., 
    pi2=..., currentDistance=0x55555f603a40) at /home/halla/dev/krita/libs/image/brushengine/kis_paintop.cc:113
#16 0x00007ffff6c4c5fb in KisPaintOp::paintBezierCurve (this=0x7fff7404c3b0, pi1=..., control1=..., 
    control2=..., pi2=..., currentDistance=0x55555f603a40)
    at /home/halla/dev/krita/libs/image/brushengine/kis_paintop.cc:136
#17 0x00007ffff6c14130 in KisPainter::paintBezierCurve (this=0x55555a2afda0, pi1=..., control1=..., 
    control2=..., pi2=..., currentDistance=0x55555f603a40)
    at /home/halla/dev/krita/libs/image/kis_painter.cc:1227
#18 0x00007ffff79367ce in KisMaskedFreehandStrokePainter::<lambda(KisFreehandStrokeInfo*)>::operator()(KisFreehan--Type <RET> for more, q to quit, c to continue without paging--
dStrokeInfo *) const (__closure=0x7fff877fdc10, data=0x55555f6c3e30)
    at /home/halla/dev/krita/libs/ui/tool/strokes/KisMaskedFreehandStrokePainter.cpp:55
#19 0x00007ffff7936fe4 in KisMaskedFreehandStrokePainter::applyToAllPainters<KisMaskedFreehandStrokePainter::paintBezierCurve(const KisPaintInformation&, const QPointF&, const QPointF&, const KisPaintInformation&)::<lambda(KisFreehandStrokeInfo*)> >(KisMaskedFreehandStrokePainter::<lambda(KisFreehandStrokeInfo*)>) (this=0x7fff74036b30, 
    func=...) at /home/halla/dev/krita/libs/ui/tool/strokes/KisMaskedFreehandStrokePainter.cpp:31
#20 0x00007ffff793682a in KisMaskedFreehandStrokePainter::paintBezierCurve (this=0x7fff74036b30, pi1=..., 
    control1=..., control2=..., pi2=...)
    at /home/halla/dev/krita/libs/ui/tool/strokes/KisMaskedFreehandStrokePainter.cpp:54
#21 0x00007ffff791e301 in FreehandStrokeStrategy::doStrokeCallback (this=0x55555f6acf60, data=0x55555f6ac180)
    at /home/halla/dev/krita/libs/ui/tool/strokes/freehand_stroke.cpp:176
#22 0x00007ffff6dd78c1 in SimpleStrokeJobStrategy::run (this=0x55555f6ae3a0, data=0x55555f6ac180)
    at /home/halla/dev/krita/libs/image/kis_simple_stroke_strategy.cpp:39
#23 0x00007ffff6ddf146 in KisStrokeJob::run (this=0x55555f490b30)
    at /home/halla/dev/krita/libs/image/kis_stroke_job.h:32
#24 0x00007ffff6bcf7cb in KisUpdateJobItem::run (this=0x55555e35d210)
    at /home/halla/dev/krita/libs/image/kis_update_job_item.h:90
#25 0x00007ffff55eeb72 in ?? () from /home/halla/dev/deps/lib/libQt5Core.so.5
#26 0x00007ffff55eb592 in ?? () from /home/halla/dev/deps/lib/libQt5Core.so.5
#27 0x00007ffff2cde609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#28 0x00007ffff523f293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Comment 7 Dmitry Kazakov 2021-12-16 08:28:34 UTC
Git commit c6af6b4e0846959169140d0bd4f143fcbba402aa by Dmitry Kazakov.
Committed on 16/12/2021 at 08:28.
Pushed by dkazakov into branch 'master'.

Fix a crash when painting with overlay-colorsmudge on tranparency masks

It happened because the color space of the mask's (and filter layer's)
paint device didn't match, therefore color picking algorithm couldn't
work. Now the color space matching is done via forcing the color space
of the layer overlay device.

M  +28   -14   libs/image/KisOverlayPaintDeviceWrapper.cpp
M  +5    -1    libs/image/KisOverlayPaintDeviceWrapper.h
M  +2    -2    plugins/paintops/colorsmudge/KisColorSmudgeStrategyWithOverlay.cpp

https://invent.kde.org/graphics/krita/commit/c6af6b4e0846959169140d0bd4f143fcbba402aa
Comment 8 Dmitry Kazakov 2021-12-16 08:30:18 UTC
Git commit 637e5c9c5c8fd7147c1937382912772ac14799c9 by Dmitry Kazakov.
Committed on 16/12/2021 at 08:30.
Pushed by dkazakov into branch 'krita/5.0'.

Fix a crash when painting with overlay-colorsmudge on tranparency masks

It happened because the color space of the mask's (and filter layer's)
paint device didn't match, therefore color picking algorithm couldn't
work. Now the color space matching is done via forcing the color space
of the layer overlay device.
(cherry picked from commit c6af6b4e0846959169140d0bd4f143fcbba402aa)

M  +28   -14   libs/image/KisOverlayPaintDeviceWrapper.cpp
M  +5    -1    libs/image/KisOverlayPaintDeviceWrapper.h
M  +2    -2    plugins/paintops/colorsmudge/KisColorSmudgeStrategyWithOverlay.cpp

https://invent.kde.org/graphics/krita/commit/637e5c9c5c8fd7147c1937382912772ac14799c9