Bug 402494

Summary: Merging down a layer with colourise mask
Product: [Applications] krita Reporter: InfinityTraveller <InfinityTraveller>
Component: Layer StackAssignee: Tiar <tamtamy.tymona>
Status: RESOLVED FIXED    
Severity: crash CC: halla, tamtamy.tymona
Priority: NOR Keywords: triaged
Version: 4.1.7   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: Crash example

Description InfinityTraveller 2018-12-23 12:22:58 UTC
Created attachment 117072 [details]
Crash example

SUMMARY
Merging down a layer with colourise mask that have an output generated causes 2 runtime error dialogue boxes to pop-up, and crashes the program.

STEPS TO REPRODUCE
1. Create a new layer, and draw a basic shape in it (I will be referring to this layer as lines layer).
2. Add a colourise mask layer to lines layer.
3. Add your colour key strokes to the colourise mask.
4. Click the update button to generate output.
5. Add a new layer on top of the lines layer.
6. Draw some lines in the new layer.
7. Merge down the top layer with lines layer using ctrl + e or the right click menu.

OBSERVED RESULT
The program crashes.

EXPECTED RESULT
Content from the top layer is merged with the lines layer, and colourise mask can be updated to reapply colours to line changes.

SOFTWARE/OS VERSIONS
Windows: Windows 8.1 64-bit

ADDITIONAL INFORMATION
- No backtrace was generated.
- The new layer can be empty and the crash occurs.
- The new layer can be below the lines layer, and merging down will crash Krita.
- Colourise mask with no output generated will NOT crash, but the key strokes will NOT be applied and colours are lost, the result will be only the lines layer and new layer merged.
- Flatten image will NOT crash Krita with this setup.
- Included an example file with the setup to crash Krita, all is needed is to merge down the 2 layers.
Comment 1 Halla Rempt 2018-12-23 13:11:56 UTC
Thanks for the report and for the extremely helpful test file! I can confirm the crash:

Application: Krita (krita), signal: Aborted
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f5878d69800 (LWP 32447))]

Thread 6 (Thread 0x7f585f7fe700 (LWP 32454)):
#0  0x00007f587d993524 in g_mutex_unlock () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007f587d94c36c in g_main_context_prepare () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f587d94cd7b in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f587d94cf6c in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007f588126a15b in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f588121716b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f58810660b6 in QThread::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f587594e1f5 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#8  0x00007f588106fc87 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007f587e7f9164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#10 0x00007f5880d39def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 5 (Thread 0x7f585effd700 (LWP 32453)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f5881064fd0 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007f5881064e42 in QSemaphore::tryAcquire(int, int) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007f587f994f33 in KisTileDataSwapper::waitForWork (this=<optimized out>) at /home/boud/dev/krita/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:86
#4  0x00007f587f99516a in KisTileDataSwapper::run (this=0x7f587fe06b00 <(anonymous namespace)::Q_QGS_s_instance::innerFunction()::holder+64>) at /home/boud/dev/krita/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:92
#5  0x00007f588106fc87 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f587e7f9164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#7  0x00007f5880d39def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 4 (Thread 0x7f585ffff700 (LWP 32451)):
#0  0x00007f5880d2d6d9 in __GI___poll (fds=0x7f5858004a10, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f587d94ce46 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f587d94cf6c in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f588126a15b in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007f588121716b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f58810660b6 in QThread::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f588106fc87 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f587e7f9164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#8  0x00007f5880d39def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7f586d58f700 (LWP 32450)):
#0  0x00007f5880d2d6d9 in __GI___poll (fds=0x7f5860019410, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f587d94ce46 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f587d94cf6c in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f588126a15b in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007f588121716b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f58810660b6 in QThread::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f587e828545 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5
#7  0x00007f588106fc87 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f587e7f9164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#9  0x00007f5880d39def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7f586f1d2700 (LWP 32449)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x55b58fdf09c8) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x55b58fdf0978, cond=0x55b58fdf09a0) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x55b58fdf09a0, mutex=0x55b58fdf0978) at pthread_cond_wait.c:655
#3  0x00007f586f6ef46b in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#4  0x00007f586f6ef1d7 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#5  0x00007f587e7f9164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#6  0x00007f5880d39def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f5878d69800 (LWP 32447)):
[KCrash Handler]
#6  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#7  0x00007f5880c41535 in __GI_abort () at abort.c:79
#8  0x00007f588102e8d7 in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007f5882133b0d in kis_assert_common (assertion=<optimized out>, file=<optimized out>, line=<optimized out>, throwException=<optimized out>, isIgnorable=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qarraydata.h:206
#10 0x00007f587fa7d408 in KisColorizeMask::slotUpdateOnDirtyParent (this=0x55b59aa616f0) at /home/boud/dev/krita/libs/global/kis_shared_ptr.h:223
#11 0x00007f58812416db in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#12 0x00007f58812416db in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#13 0x00007f58812416db in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#14 0x00007f588214c723 in KisRelaxedTimer::timerEvent (this=0x55b59aa650f0, event=<optimized out>) at /home/boud/dev/krita/libs/global/kis_relaxed_timer.cpp:100
#15 0x00007f5881241f4b in QObject::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007f5881bd94a1 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007f5881be0ae0 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007f5882c8abf7 in KisApplication::notify (this=<optimized out>, receiver=0x55b59aa650f0, event=0x7ffc76f3c100) at /home/boud/dev/krita/libs/ui/KisApplication.cpp:608
#19 0x00007f5881218499 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#20 0x00007f5881269558 in QTimerInfoList::activateTimers() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x00007f5881269dec in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007f587d94cc3e in g_main_context_dispatch () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#23 0x00007f587d94ced8 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#24 0x00007f587d94cf6c in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007f588126a143 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#26 0x00007f58786ede51 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#27 0x00007f588121716b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x00007f588121f2e2 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#29 0x000055b58ddb6ed8 in main (argc=<optimized out>, argv=0x7ffc76f3c688) at /home/boud/dev/krita/krita/main.cc:459
[Inferior 1 (process 32447) detached]
Comment 2 Tiar 2019-03-28 20:41:05 UTC
Git commit 630ce8583cb5a9337aceb2ca96f17c2cf1df306e by Agata Cacko.
Committed on 28/03/2019 at 20:34.
Pushed by tymond into branch 'master'.

Disable assert on empty parent in Colorize Mask

Before this change, Colorize Mask asserted after flattening
or merging with another layer when the image was smaller than 1024px
wide and long. After this commit, it shouldn't happen.

It was caused by setting the parent dirty just before the parent gets
deleted. The request was linked to refreshing area outside the image
boundaries; since Colorize Mask didn't and doesn't work outside of the
image boundaries, it isn't necessary.

NOTE: In case of providing support for Colorize Mask working outside of
the canvas boundaries, the decision in this commit might need
reevaluation (in case of a need to update the mask there).

M  +9    -1    libs/image/lazybrush/kis_colorize_mask.cpp

https://commits.kde.org/krita/630ce8583cb5a9337aceb2ca96f17c2cf1df306e