Bug 451912

Summary: Crash when smart patch tool used in EXR HDR layer
Product: krita Reporter: yurinikolai00
Component: HDRAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: dimula73
Priority: NOR    
Version: 5.0.2   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In:

Description yurinikolai00 2022-03-25 23:58:15 UTC
SUMMARY

GDB Backtrace: 
#0  0x00007ffff5a0134c in __pthread_kill_implementation () at /usr/lib/libc.so.6
#1  0x00007ffff59b44b8 in raise () at /usr/lib/libc.so.6
#2  0x00007ffff599e534 in abort () at /usr/lib/libc.so.6
#3  0x00007fffa43e8f7a in  () at /usr/lib/kritaplugins/kritatoolSmartPatch.so
#4  0x00007fffa43ef06f in  () at /usr/lib/kritaplugins/kritatoolSmartPatch.so
#5  0x00007fffa43eaa39 in  () at /usr/lib/kritaplugins/kritatoolSmartPatch.so
#6  0x00007ffff73aed4c in KisTransactionBasedCommand::redo() ()
    at /usr/lib/libkritaimage.so.17
#7  0x00007ffff7439087 in KisStrokeStrategyUndoCommandBased::doStrokeCallback(KisStrokeJobData*) () at /usr/lib/libkritaimage.so.17
#8  0x00007ffff73496a4 in  () at /usr/lib/libkritaimage.so.17
#9  0x00007ffff5ea5aa2 in  () at /usr/lib/libQt5Core.so.5
#10 0x00007ffff5ea18cc in  () at /usr/lib/libQt5Core.so.5
#11 0x00007ffff59ff5c2 in start_thread () at /usr/lib/libc.so.6
#12 0x00007ffff5a84584 in clone () at /usr/lib/libc.so.6


STEPS TO REPRODUCE
1. Open EXR with 32-bit float/channel RGB/Alpha colour space and sRGB-elle-v2-g10 profile. This is the one i was testing on Krita: https://drive.google.com/file/d/1GiXmsfYesfI3wSQN3wVJU_dg-LF0W3WH/view?usp=sharing
2. Add another layer filled with black behind it, purely to make viewing easier
3. Select smart patch tool. Not sure if area matters but i was testing a small brush size on the little white dot on the image's upper part. Trying to use it makes the program crash, sometimes on the first try, sometimes after 2-3 uses of the tool.

OBSERVED RESULT
Program crashed, closing immediately on normal usage (repeated three times) and freezing forever while running through Gdb.

EXPECTED RESULT
Smart patch to behave in EXR files as it does with "normal" images

SOFTWARE/OS VERSIONS

Using Xfce
Qt Version: 5.15.3
Krita version 5.0.2

ADDITIONAL INFORMATION

Terminal output when opening Krita: 

Set style "breeze"
Invalid profile :  "/usr/share/color/icc/colord/Crayons.icc" "Crayon Colors"
Invalid profile :  "/usr/share/color/icc/colord/x11-colors.icc" "X11 Colors"
Loading plugin "/usr/lib/kritaplugins/kritaseexprgenerator.so" failed,  "Cannot load library /usr/lib/kritaplugins/kritaseexprgenerator.so: (libKSeExprUI.so.4: cannot open shared object file: No such file or directory)"
QObject::startTimer: Timers cannot have negative intervals
/usr/lib/krita-python-libs/krita added to PYTHONPATH
Comment 1 Dmitry Kazakov 2022-03-29 11:31:25 UTC
I can reproduce the issue
Comment 2 Dmitry Kazakov 2022-03-29 13:02:39 UTC
Git commit 237e64119a1c54fc72a5c21d4a32a6ba40bf6875 by Dmitry Kazakov.
Committed on 29/03/2022 at 13:02.
Pushed by dkazakov into branch 'master'.

Fix a crash when smart patch tool is used on an HDR image

The difference between channel values in HDR color spaces
may be higher than `unitValue`, and we should catch this case.

M  +12   -8    plugins/tools/tool_smart_patch/kis_inpaint.cpp

https://invent.kde.org/graphics/krita/commit/237e64119a1c54fc72a5c21d4a32a6ba40bf6875
Comment 3 Dmitry Kazakov 2022-03-29 13:03:19 UTC
Git commit 5d2860885a643bf150c7b563ca7c82b5465e7c6f by Dmitry Kazakov.
Committed on 29/03/2022 at 13:03.
Pushed by dkazakov into branch 'krita/5.0'.

Fix a crash when smart patch tool is used on an HDR image

The difference between channel values in HDR color spaces
may be higher than `unitValue`, and we should catch this case.

M  +12   -8    plugins/tools/tool_smart_patch/kis_inpaint.cpp

https://invent.kde.org/graphics/krita/commit/5d2860885a643bf150c7b563ca7c82b5465e7c6f