Bug 373835

Summary: Hiding a layer causes krita to crash at times.
Product: [Applications] krita Reporter: laerne <nicolas.brack>
Component: Layer StackAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: halla
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: A file that causes a crash
The stack trace

Description laerne 2016-12-18 15:10:47 UTC
My layer structure was as such.  A bottom layer with a grey color, locked.  A middle layer with a dark grey square as a palette, locked.  A top layer group containing only one unlocked paint layer.

After a quick 60 seconds sketch on the unlocked paint layer, I created a layer on top of it and I hide the layer I just painted with.  Krita crashes, sometimes immediately, sometimes within several seconds.

I attach the file that causes the crash, so you can test it up yourselves.  Open the file with krita, Select "Layer 2", create a layer with the "+" button and hide "layer 2" with the eye icon.  Krita should crash.

Here is the stack trace of the main thread that called "abort()" :
Thread 1 (Thread 0x7fd4bdceb0c0 (LWP 9536)):
[KCrash Handler]
#6  0x00007fd4c7e2692f in raise () at /lib64/libc.so.6
#7  0x00007fd4c7e2852a in abort () at /lib64/libc.so.6
#8  0x00007fd4c8af0b21 in  () at /lib64/libQt5Core.so.5
#9  0x00007fd4c8aebfee in  () at /lib64/libQt5Core.so.5
#10 0x00007fd4d0016761 in KisPaintDeviceCache::createThumbnail(int, int, double, KoColorConversionTransformation::Intent, QFlags<KoColorConversionTransformation::ConversionFlag>) (this=0x9aa35c8, w=20, h=0, oversample=1, renderingIntent=KoColorConversionTransformation::IntentPerceptual, conversionFlags=...) at /media/data/linux.64/PROJECTS/krita/libs/image/kis_paint_device_cache.h:104
#11 0x00007fd4d0012777 in KisPaintDevice::createThumbnail(int, int, double, KoColorConversionTransformation::Intent, QFlags<KoColorConversionTransformation::ConversionFlag>) (this=0x9aa3460, w=20, h=0, oversample=1, renderingIntent=KoColorConversionTransformation::IntentPerceptual, conversionFlags=...) at /media/data/linux.64/PROJECTS/krita/libs/image/kis_paint_device.cc:1636
#12 0x00007fd4cffd03b0 in KisLayer::createThumbnail(int, int) (this=0x9aa3010, w=20, h=0) at /media/data/linux.64/PROJECTS/krita/libs/image/kis_layer.cc:794
#13 0x00007fd4d11202b1 in KisNodeModel::data(QModelIndex const&, int) const (this=0x938fc70, index=..., role=120) at /media/data/linux.64/PROJECTS/krita/libs/ui/kis_node_model.cpp:480
#14 0x00007fd4c8c736b9 in QSortFilterProxyModel::data(QModelIndex const&, int) const () at /lib64/libQt5Core.so.5
#15 0x00007fd4d10ae1a9 in QModelIndex::data(int) const (this=0x7ffeb505f4f0, arole=120) at /usr/include/qt5/QtCore/qabstractitemmodel.h:426
#16 0x00007fd4d13a3148 in KisNodeDelegate::drawThumbnail(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const (this=0x9376740, p=0x7ffeb505f860, option=..., index=...) at /media/data/linux.64/PROJECTS/krita/libs/ui/KisNodeDelegate.cpp:274
#17 0x00007fd4d13a1ca6 in KisNodeDelegate::paint(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const (this=0x9376740, p=0x7ffeb505f860, o=..., index=...) at /media/data/linux.64/PROJECTS/krita/libs/ui/KisNodeDelegate.cpp:112
#18 0x00007fd4c9777988 in QTreeView::drawRow(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const () at /lib64/libQt5Widgets.so.5
#19 0x00007fd4c977d4b7 in QTreeView::drawTree(QPainter*, QRegion const&) const () at /lib64/libQt5Widgets.so.5
#20 0x00007fd4c9781f46 in QTreeView::paintEvent(QPaintEvent*) () at /lib64/libQt5Widgets.so.5
#21 0x00007fd4d13ab804 in KisNodeView::paintEvent(QPaintEvent*) (this=0x93705e0, event=0x7ffeb5060680) at /media/data/linux.64/PROJECTS/krita/libs/ui/KisNodeView.cpp:446
#22 0x00007fd4c9534c40 in QWidget::event(QEvent*) () at /lib64/libQt5Widgets.so.5
#23 0x00007fd4c961c8ee in QFrame::event(QEvent*) () at /lib64/libQt5Widgets.so.5
#24 0x00007fd4c9743783 in QAbstractItemView::viewportEvent(QEvent*) () at /lib64/libQt5Widgets.so.5
#25 0x00007fd4c9782dfc in QTreeView::viewportEvent(QEvent*) () at /lib64/libQt5Widgets.so.5
#26 0x00007fd4d13aa7ac in KisNodeView::viewportEvent(QEvent*) (this=0x93705e0, e=0x7ffeb5060680) at /media/data/linux.64/PROJECTS/krita/libs/ui/KisNodeView.cpp:290
#27 0x00007fd4c8ca4ed2 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () at /lib64/libQt5Core.so.5
#28 0x00007fd4c94ed945 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /lib64/libQt5Widgets.so.5
#29 0x00007fd4c94f5111 in QApplication::notify(QObject*, QEvent*) () at /lib64/libQt5Widgets.so.5
#30 0x00007fd4d1385aa9 in KisApplication::notify(QObject*, QEvent*) (this=0x7ffeb5061470, receiver=0x9372460, event=0x7ffeb5060680) at /media/data/linux.64/PROJECTS/krita/libs/ui/KisApplication.cpp:519
#31 0x00007fd4c8ca50ea in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /lib64/libQt5Core.so.5
#32 0x00007fd4c952d98a in QWidgetPrivate::sendPaintEvent(QRegion const&) () at /lib64/libQt5Widgets.so.5
#33 0x00007fd4c952dfe5 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () at /lib64/libQt5Widgets.so.5
#34 0x00007fd4c94fdb8c in QWidgetBackingStore::doSync() () at /lib64/libQt5Widgets.so.5
#35 0x00007fd4c94fddcf in QWidgetBackingStore::sync() () at /lib64/libQt5Widgets.so.5
#36 0x00007fd4c951cd1f in QWidgetPrivate::syncBackingStore() () at /lib64/libQt5Widgets.so.5
#37 0x00007fd4c9534d18 in QWidget::event(QEvent*) () at /lib64/libQt5Widgets.so.5
#38 0x00007fd4c96337bb in QMainWindow::event(QEvent*) () at /lib64/libQt5Widgets.so.5
#39 0x00007fd4cdd793b0 in KMainWindow::event(QEvent*) (this=0x88823a0, ev=0xc6b3e30) at /media/data/linux.64/PROJECTS/krita/libs/widgetutils/xmlgui/kmainwindow.cpp:780
#40 0x00007fd4cddaeaa5 in KXmlGuiWindow::event(QEvent*) (this=0x88823a0, ev=0xc6b3e30) at /media/data/linux.64/PROJECTS/krita/libs/widgetutils/xmlgui/kxmlguiwindow.cpp:125
#41 0x00007fd4c94ed96c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /lib64/libQt5Widgets.so.5
#42 0x00007fd4c94f5111 in QApplication::notify(QObject*, QEvent*) () at /lib64/libQt5Widgets.so.5
#43 0x00007fd4d1385aa9 in KisApplication::notify(QObject*, QEvent*) (this=0x7ffeb5061470, receiver=0x88823a0, event=0xc6b3e30) at /media/data/linux.64/PROJECTS/krita/libs/ui/KisApplication.cpp:519
#44 0x00007fd4c8ca50ea in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /lib64/libQt5Core.so.5
#45 0x00007fd4c8ca77d0 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /lib64/libQt5Core.so.5
#46 0x00007fd4c8cf2ce3 in postEventSourceDispatch(_GSource*, int (*)(void*), void*) () at /lib64/libQt5Core.so.5
#47 0x00007fd4c1e80e42 in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
#48 0x00007fd4c1e811c0 in g_main_context_iterate.isra () at /lib64/libglib-2.0.so.0
#49 0x00007fd4c1e8126c in g_main_context_iteration () at /lib64/libglib-2.0.so.0
#50 0x00007fd4c8cf2d5f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib64/libQt5Core.so.5
#51 0x00007fd4c8ca407a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib64/libQt5Core.so.5
#52 0x00007fd4c8cabb7c in QCoreApplication::exec() () at /lib64/libQt5Core.so.5
#53 0x0000000000408d58 in main(int, char**) (argc=1, argv=0x7ffeb5061b08) at /media/data/linux.64/PROJECTS/krita/krita/main.cc:258
Comment 1 laerne 2016-12-18 15:16:04 UTC
Created attachment 102857 [details]
A file that causes a crash
Comment 2 laerne 2016-12-18 15:17:56 UTC
Created attachment 102858 [details]
The stack trace

Sorry for pasting the stack trace before because I saw only one entry to attach a document.  Here is a proper text file with it.
Comment 3 Halla Rempt 2016-12-22 11:31:31 UTC
Hi Nicolas,

I'm sorry, but I haven't been able to reproduce this issue. It sounds like a timing issue though, since it happens in the generation of a thumbnail for a layer. What cmake build type are you using?
Comment 4 Halla Rempt 2017-01-25 10:05:26 UTC
Wait....

#10 0x00007fd4d0016761 in KisPaintDeviceCache::createThumbnail(int, int, double, KoColorConversionTransformation::Intent, QFlags<KoColorConversionTransformation::ConversionFlag>) (this=0x9aa35c8, w=20, h=0, oversample=1, 

A thumbnail with h==0? That might explain some things.
Comment 5 Halla Rempt 2017-01-25 10:11:33 UTC
Git commit 2beef4d7cf4967f1f299aba989ff64c4465c26fe by Boudewijn Rempt.
Committed on 25/01/2017 at 10:11.
Pushed by rempt into branch 'master'.

M  +4    -0    libs/image/kis_layer.cc
M  +6    -2    libs/image/kis_paint_device_cache.h
M  +4    -0    libs/ui/kis_node_model.cpp

https://commits.kde.org/krita/2beef4d7cf4967f1f299aba989ff64c4465c26fe
Comment 6 Halla Rempt 2017-01-25 10:11:45 UTC
Git commit bc167bc7a5fefdf08bb30b1571fdc356e4c5dcfe by Boudewijn Rempt.
Committed on 25/01/2017 at 10:11.
Pushed by rempt into branch 'krita/3.1'.

M  +4    -0    libs/image/kis_layer.cc
M  +6    -2    libs/image/kis_paint_device_cache.h
M  +4    -0    libs/ui/kis_node_model.cpp

https://commits.kde.org/krita/bc167bc7a5fefdf08bb30b1571fdc356e4c5dcfe