Bug 389503

Summary: Assertion failure/crash pasting transparency mask layer
Product: [Applications] krita Reporter: lou
Component: Layer StackAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: griffinvalley, halla
Priority: NOR Keywords: regression
Version: 4.0 pre-alpha   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: kras for reproduction

Description lou 2018-01-27 10:50:07 UTC
Created attachment 110147 [details]
kras for reproduction

> QFileInfo::absolutePath: Constructed with empty filename
> ASSERT (krita): "lod > 0" in file /tmp/nix-build-krita-4.0.0-pre2c.drv-0/krita-4.0.0-prealpha.2/libs/image/kis_paint_device.cc, line 692
> KCrash: Application 'krita' crashing...

I haven't been able to isolate the issue very well; it can be triggered by "copy layer" on the transparency mask from b.kra to a.kra. It will do the paste, the canvas will have an an inner nontransparent area, a middle transparent area, and an outer nontransparent area (which seems odd), and will crash after a couple seconds.

It may have something to do with the canvas size?

I'm not even sure this is my original crash I wsa trying to isolate but it seems to be similar so...
Comment 1 Halla Rempt 2018-01-27 11:11:52 UTC
I cannot reproduce this with the current git master; the alpha is pretty old by now.
Comment 2 lou 2018-01-27 15:39:44 UTC
I just built from master and I still crash.
Here's the system info I get.

> OpenGL Info
>  Vendor:  Intel Open Source Technology Center
>  Renderer:  "Mesa DRI Intel(R) HD Graphics 5500 (Broadwell GT2) "
>  Version:  "3.0 Mesa 17.0.7"
>  Shading language:  1.30
>  Requested format:  QSurfaceFormat(version 3.0, options QFlags(0x4), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 0, profile  2)
>  Current format:    QSurfaceFormat(version 3.0, options QFlags(0x4), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 0, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 0, profile  0)
>     Version: 3.0
>     Supports deprecated functions true
>     is OpenGL ES: false
>krita has opengl true
>Available translations QSet("en_US")
>Available domain translations QSet("en_US")
>Override language: ""
>Setting Krita's language to: QLocale(English, Latin, UnitedStates)
>krita 4.0.0-beta1
Comment 3 wolthera 2018-01-28 16:02:54 UTC
Required instant preview to be on, and I am on an intel device:

GDB backtrace:
---------------------------
ASSERT (krita): "lod > 0" in file /home/wolthera/krita/src/libs/image/kis_paint_device.cc, line 701

Thread 27 "Thread (pooled)" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff9b7fe700 (LWP 28676)]
0x00007ffff48df428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) thread apply all backtrace

Thread 27 (Thread 0x7fff9b7fe700 (LWP 28676)):
#0  0x00007ffff48df428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff48e102a in __GI_abort () at abort.c:89
#2  0x00007ffff52a0c71 in QMessageLogger::fatal(char const*, ...) const ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007ffff6b4abdf in kis_assert_common (assertion=assertion@entry=0x7ffff27943c0 "lod > 0", 
    file=file@entry=0x7ffff2794168 "/home/wolthera/krita/src/libs/image/kis_paint_device.cc", 
    line=line@entry=701, throwException=throwException@entry=false, isIgnorable=isIgnorable@entry=false)
    at /home/wolthera/krita/src/libs/global/kis_assert.cpp:90
#4  0x00007ffff6b4af4a in kis_assert_recoverable (assertion=assertion@entry=0x7ffff27943c0 "lod > 0", 
    file=file@entry=0x7ffff2794168 "/home/wolthera/krita/src/libs/image/kis_paint_device.cc", line=line@entry=701)
    at /home/wolthera/krita/src/libs/global/kis_assert.cpp:103
#5  0x00007ffff269cade in KisPaintDevice::Private::updateLodDataStruct (this=0x13ef0990, _dst=<optimized out>, 
    originalRect=...) at /home/wolthera/krita/src/libs/image/kis_paint_device.cc:701
#6  0x00007ffff269cce9 in KisPaintDevice::updateLodDataStruct (this=<optimized out>, dst=<optimized out>, 
    srcRect=...) at /home/wolthera/krita/src/libs/image/kis_paint_device.cc:2020
#7  0x00007ffff263eeda in KisSyncLodCacheStrokeStrategy::doStrokeCallback (this=0x13ec05d0, data=<optimized out>)
    at /home/wolthera/krita/src/libs/image/kis_sync_lod_cache_stroke_strategy.cpp:108
#8  0x00007ffff2787d66 in KisStrokeJob::run (this=<optimized out>)
    at /home/wolthera/krita/build/libs/image/../../../src/libs/image/kis_stroke_job.h:44
#9  KisUpdateJobItem::run (this=0xe98a780)
    at /home/wolthera/krita/build/libs/image/../../../src/libs/image/kis_update_job_item.h:90
#10 0x00007ffff52b4b27 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#11 0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---
#12 0x00007fffee43b6ba in start_thread (arg=0x7fff9b7fe700) at pthread_create.c:333
#13 0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 26 (Thread 0x7fff9bfff700 (LWP 28675)):
#0  pthread_cond_timedwait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225
#1  0x00007ffff52b9596 in QWaitCondition::wait(QMutex*, unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007ffff52b4dea in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007fffee43b6ba in start_thread (arg=0x7fff9bfff700) at pthread_create.c:333
#5  0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 25 (Thread 0x7fffa90f3700 (LWP 28674)):
#0  pthread_cond_timedwait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225
#1  0x00007ffff52b9596 in QWaitCondition::wait(QMutex*, unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007ffff52b4dea in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007fffee43b6ba in start_thread (arg=0x7fffa90f3700) at pthread_create.c:333
#5  0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 24 (Thread 0x7fffa88f2700 (LWP 28673)):
#0  pthread_cond_timedwait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225
#1  0x00007ffff52b9596 in QWaitCondition::wait(QMutex*, unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---
#2  0x00007ffff52b4dea in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007fffee43b6ba in start_thread (arg=0x7fffa88f2700) at pthread_create.c:333
#5  0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 8 (Thread 0x7fffab47f700 (LWP 28551)):
#0  0x00007ffff49a570d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007fffece4238c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fffece4249c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ffff54e26af in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff548ae2a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff52b38f4 in QThread::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007fffd5f94d25 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#7  0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007fffee43b6ba in start_thread (arg=0x7fffab47f700) at pthread_create.c:333
#9  0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 6 (Thread 0x7fffb90dc700 (LWP 28549)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007ffff52b965b in QWaitCondition::wait(QMutex*, unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007ffff63ff84a in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#3  0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---
#4  0x00007fffee43b6ba in start_thread (arg=0x7fffb90dc700) at pthread_create.c:333
#5  0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 5 (Thread 0x7fffb88db700 (LWP 28548)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007ffff52b965b in QWaitCondition::wait(QMutex*, unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007ffff52b25ff in QSemaphore::tryAcquire(int, int) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007ffff254d743 in KisTileDataSwapper::waitForWork (this=<optimized out>)
    at /home/wolthera/krita/src/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:86
#4  0x00007ffff254d93a in KisTileDataSwapper::run (
    this=0x7ffff2a49f40 <(anonymous namespace)::Q_QGS_s_instance::innerFunction()::holder+64>)
    at /home/wolthera/krita/src/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:92
#5  0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007fffee43b6ba in start_thread (arg=0x7fffb88db700) at pthread_create.c:333
#7  0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 3 (Thread 0x7fffd0a5f700 (LWP 28546)):
#0  0x00007ffff49a570d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007fffece4238c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fffece4249c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ffff54e26af in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff548ae2a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---
#5  0x00007ffff52b38f4 in QThread::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007fffee667315 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5
#7  0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007fffee43b6ba in start_thread (arg=0x7fffd0a5f700) at pthread_create.c:333
#9  0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 2 (Thread 0x7fffdd1e8700 (LWP 28545)):
#0  0x00007ffff49a570d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007ffff2ca7c62 in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#2  0x00007ffff2ca98d7 in xcb_wait_for_event () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#3  0x00007fffdf52f1f9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#4  0x00007ffff52b8709 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007fffee43b6ba in start_thread (arg=0x7fffdd1e8700) at pthread_create.c:333
#6  0x00007ffff49b13dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 1 (Thread 0x7ffff7f07900 (LWP 28541)):
#0  0x00007fffdf5988e8 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#1  0x00007ffff5be6dc9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#2  0x00007fffedf70e5a in ?? () from /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
#3  0x00007fffedf41a42 in hb_shape_plan_execute () from /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
#4  0x00007fffedf410a2 in hb_shape_full () from /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
#5  0x00007ffff5b4f7eb in QTextEngine::shapeTextWithHarfbuzzNG(QScriptItem const&, unsigned short const*, int, QFontEngine*, QVector<unsigned int> const&, bool, bool) const () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#6  0x00007ffff5b52524 in QTextEngine::shapeText(int) const () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#7  0x00007ffff5b5318d in QTextEngine::shape(int) const () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
---Type <return> to continue, or q <return> to quit---
#8  0x00007ffff5b59d82 in QTextEngine::width(int, int) const () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#9  0x00007ffff5b3d3c7 in QFontMetrics::width(QString const&, int, int) const ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#10 0x00007ffff218cc25 in KoDockWidgetTitleBar::sizeHint (this=0xe4eafa0)
    at /home/wolthera/krita/src/libs/widgets/KoDockWidgetTitleBar.cpp:149
#11 0x00007ffff630c731 in QDockWidgetLayout::titleHeight() const ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007ffff630e47d in QDockWidgetLayout::sizeFromContent(QSize const&, bool) const ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007ffff630ea21 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007ffff63123e0 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007ffff63121d9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007ffff6312428 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ffff63121d9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007ffff6316a72 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007ffff6319018 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff634a91d in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007ffff620618f in QLayoutPrivate::doResize(QSize const&) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007ffff6207268 in QLayout::activate() () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#23 0x00007ffff61e9b6a in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#24 0x00007ffff61f15a7 in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007ffff7859e57 in KisApplication::notify (this=<optimized out>, receiver=0xbd59610, event=0x11f29180)
---Type <return> to continue, or q <return> to quit---
    at /home/wolthera/krita/src/libs/ui/KisApplication.cpp:600
#26 0x00007ffff548cdf8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#27 0x00007ffff548f5db in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x00007ffff54e30a3 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#29 0x00007fffece42197 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x00007fffece423f0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#31 0x00007fffece4249c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#32 0x00007ffff54e26af in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#33 0x00007ffff548ae2a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#34 0x00007ffff5493d64 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#35 0x00000000004058a4 in main (argc=1, argv=<optimized out>) at /home/wolthera/krita/src/krita/main.cc:312
(gdb) 
(gdb)
Comment 4 Dmitry Kazakov 2018-02-27 11:08:15 UTC
It looks like the layer's device gets copied with incorrect LoD state or without locking. And hence the crash.
Comment 5 Dmitry Kazakov 2018-02-28 11:18:20 UTC
Okay, seems like I can reproduce the crash now :)
Comment 6 Dmitry Kazakov 2018-02-28 12:31:11 UTC
Git commit cefc22a0327e681743a34747628eca378ea9edfc by Dmitry Kazakov.
Committed on 28/02/2018 at 12:29.
Pushed by dkazakov into branch 'master'.

Avoid sanity check assert when D&D layers between two images

The document should not be destroyed with the image still assigned
and alive :)

M  +7    -1    libs/ui/kis_mimedata.cpp

https://commits.kde.org/krita/cefc22a0327e681743a34747628eca378ea9edfc
Comment 7 Dmitry Kazakov 2018-02-28 12:31:11 UTC
Git commit 6772d6678109e5e839fea24c7de1198dcda249a4 by Dmitry Kazakov.
Committed on 28/02/2018 at 12:29.
Pushed by dkazakov into branch 'master'.

Fix resetting the default bounds of the layer projection when assigning to a new image

M  +2    -0    libs/image/kis_cached_paint_device.h
M  +6    -0    libs/image/kis_layer.cc
M  +3    -5    libs/ui/kis_mimedata.cpp

https://commits.kde.org/krita/6772d6678109e5e839fea24c7de1198dcda249a4