Bug 372156 - Assert hit in KisPaintDeviceCache::createThumbnail
Summary: Assert hit in KisPaintDeviceCache::createThumbnail
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Layer Stack (show other bugs)
Version: 3.1 Beta
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Frederik Gladhorn
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-06 20:47 UTC by Frederik Gladhorn
Modified: 2016-11-09 11:00 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederik Gladhorn 2016-11-06 20:47:49 UTC
Luckily I was running in gdb.
I attempted the follow the animation tutorial and tried to create a layer containing only a horizontal line, which explains why the assert would trigger, see below.



ASSERT: "!thumbnail.isNull() || m_paintDevice->extent().isEmpty()" in file /home/frederik/dev/kde/krita/libs/image/kis_paint_device_cache.h, line 104

Thread 1 "krita" received signal SIGABRT, Aborted.
0x00007fffed58d04f in raise () from /usr/lib/libc.so.6
(gdb) bg
Undefined command: "bg".  Try "help".                                                                                                                            
(gdb) bt                                                                                                                                                         
#0  0x00007fffed58d04f in raise () from /usr/lib/libc.so.6                                                                                                       
#1  0x00007fffed58e47a in abort () from /usr/lib/libc.so.6                                                                                                       
#2  0x00007fffee243668 in qt_message_fatal (context=..., message=...) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/global/qlogging.cpp:1683               
#3  0x00007fffee24579e in QMessageLogger::fatal (this=0x7fffffff85a8, msg=0x7fffee621274 "ASSERT: \"%s\" in file %s, line %d")                                      
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/global/qlogging.cpp:795                                                                                      
#4  0x00007fffee23ae12 in qt_assert (assertion=0x7ffff636a5d0 "!thumbnail.isNull() || m_paintDevice->extent().isEmpty()",                                               
    file=0x7ffff636a588 "/home/frederik/dev/kde/krita/libs/image/kis_paint_device_cache.h", line=104) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/global/qglobal.cpp:3064
#5  0x00007ffff620c069 in KisPaintDeviceCache::createThumbnail (this=0xa59a6e8, w=20, h=0, oversample=1, renderingIntent=KoColorConversionTransformation::IntentPerceptual, 
    conversionFlags=...) at /home/frederik/dev/kde/krita/libs/image/kis_paint_device_cache.h:104                                                                        
#6  0x00007ffff6208077 in KisPaintDevice::createThumbnail (this=0xa7f4150, w=20, h=0, oversample=1, renderingIntent=KoColorConversionTransformation::IntentPerceptual, 
    conversionFlags=...) at /home/frederik/dev/kde/krita/libs/image/kis_paint_device.cc:1636
#7  0x00007ffff61ba6de in KisLayer::createThumbnail (this=0xa3e63e0, w=20, h=0) at /home/frederik/dev/kde/krita/libs/image/kis_layer.cc:794
#8  0x00007ffff7543ce9 in KisNodeModel::data (this=0x9d93a40, index=..., role=120) at /home/frederik/dev/kde/krita/libs/ui/kis_node_model.cpp:480
#9  0x00007fffee4d377d in QSortFilterProxyModel::data (this=0x9d93c70, index=..., role=120)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp:1975
#10 0x00007ffff74d176b in QModelIndex::data (this=0x7fffffff9088, arole=120) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/itemmodels/qabstractitemmodel.h:432
#11 0x00007ffff778c00a in KisNodeDelegate::drawThumbnail (this=0x9d8c630, p=0x7fffffff9540, option=..., index=...) at /home/frederik/dev/kde/krita/libs/ui/KisNodeDelegate.cpp:274
#12 0x00007ffff778ab68 in KisNodeDelegate::paint (this=0x9d8c630, p=0x7fffffff9540, o=..., index=...) at /home/frederik/dev/kde/krita/libs/ui/KisNodeDelegate.cpp:112
#13 0x00007fffef3ec0eb in QTreeView::drawRow (this=0x9d879c0, painter=0x7fffffff9540, option=..., index=...)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/itemviews/qtreeview.cpp:1768
#14 0x00007fffef3e9d1c in QTreeView::drawTree (this=0x9d879c0, painter=0x7fffffff9540, region=...) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/itemviews/qtreeview.cpp:1509
#15 0x00007fffef3e96dc in QTreeView::paintEvent (this=0x9d879c0, event=0x7fffffffb3d0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/itemviews/qtreeview.cpp:1338
#16 0x00007ffff77946c6 in KisNodeView::paintEvent (this=0x9d879c0, event=0x7fffffffb3d0) at /home/frederik/dev/kde/krita/libs/ui/KisNodeView.cpp:446
#17 0x00007fffef0b1157 in QWidget::event (this=0x9d879c0, event=0x7fffffffb3d0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qwidget.cpp:8932
#18 0x00007fffef20485b in QFrame::event (this=0x9d879c0, e=0x7fffffffb3d0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/widgets/qframe.cpp:550
#19 0x00007fffef2c2296 in QAbstractScrollArea::viewportEvent (this=0x9d879c0, e=0x7fffffffb3d0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/widgets/qabstractscrollarea.cpp:1207
#20 0x00007fffef392b27 in QAbstractItemView::viewportEvent (this=0x9d879c0, event=0x7fffffffb3d0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/itemviews/qabstractitemview.cpp:1747
#21 0x00007fffef3e94c5 in QTreeView::viewportEvent (this=0x9d879c0, event=0x7fffffffb3d0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/itemviews/qtreeview.cpp:1320
#22 0x00007ffff779366e in KisNodeView::viewportEvent (this=0x9d879c0, e=0x7fffffffb3d0) at /home/frederik/dev/kde/krita/libs/ui/KisNodeView.cpp:290
#23 0x00007fffef2c3c8f in QAbstractScrollAreaPrivate::viewportEvent (this=0x9d87a10, event=0x7fffffffb3d0)
    at .moc/../../../../../qt-src-dev/qtbase/src/widgets/widgets/qabstractscrollarea_p.h:112
#24 0x00007fffef2c3b65 in QAbstractScrollAreaFilter::eventFilter (this=0x9d896d0, o=0x9d88040, e=0x7fffffffb3d0)
    at .moc/../../../../../qt-src-dev/qtbase/src/widgets/widgets/qabstractscrollarea_p.h:128
#25 0x00007fffee51668a in QCoreApplicationPrivate::sendThroughObjectEventFilters (receiver=0x9d88040, event=0x7fffffffb3d0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1099
#26 0x00007fffef051035 in QApplicationPrivate::notify_helper (this=0xbb7ec0, receiver=0x9d88040, e=0x7fffffffb3d0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qapplication.cpp:3739
#27 0x00007fffef055de9 in QApplication::notify (this=0x7fffffffd8a0, receiver=0x9d88040, e=0x7fffffffb3d0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qapplication.cpp:3706
#28 0x00007ffff7773c2b in KisApplication::notify (this=0x7fffffffd8a0, receiver=0x9d88040, event=0x7fffffffb3d0) at /home/frederik/dev/kde/krita/libs/ui/KisApplication.cpp:519
#29 0x00007fffee5162ad in QCoreApplication::notifyInternal2 (receiver=0x9d88040, event=0x7fffffffb3d0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:988
#30 0x00007fffef05a27c in QCoreApplication::sendSpontaneousEvent (receiver=0x9d88040, event=0x7fffffffb3d0)
    at ../../include/QtCore/../../../../qt-src-dev/qtbase/src/corelib/kernel/qcoreapplication.h:234
#31 0x00007fffef0a9474 in QWidgetPrivate::sendPaintEvent (this=0x9d88080, toBePainted=...) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qwidget.cpp:5704
#32 0x00007fffef0a8fa0 in QWidgetPrivate::drawWidget (this=0x9d88080, pdev=0xe65d300, rgn=..., offset=..., flags=36, sharedPainter=0x0, backingStore=0xa1d43c0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qwidget.cpp:5644
#33 0x00007fffef0683e0 in QWidgetBackingStore::doSync (this=0xa1d43c0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qwidgetbackingstore.cpp:1383
#34 0x00007fffef0669cc in QWidgetBackingStore::sync (this=0xa1d43c0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qwidgetbackingstore.cpp:1170
#35 0x00007fffef09ee13 in QWidgetPrivate::syncBackingStore (this=0x9146d90) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qwidget.cpp:1962
#36 0x00007fffef0b184a in QWidget::event (this=0x93296b0, event=0xe6653a0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qwidget.cpp:9095
#37 0x00007fffef226746 in QMainWindow::event (this=0x93296b0, event=0xe6653a0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/widgets/qmainwindow.cpp:1557
#38 0x00007ffff3ef131e in KMainWindow::event (this=0x93296b0, ev=0xe6653a0) at /home/frederik/dev/kde/krita/libs/widgetutils/xmlgui/kmainwindow.cpp:780
#39 0x00007ffff3f26c43 in KXmlGuiWindow::event (this=0x93296b0, ev=0xe6653a0) at /home/frederik/dev/kde/krita/libs/widgetutils/xmlgui/kxmlguiwindow.cpp:125
#40 0x00007fffef05105f in QApplicationPrivate::notify_helper (this=0xbb7ec0, receiver=0x93296b0, e=0xe6653a0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qapplication.cpp:3743
#41 0x00007fffef055de9 in QApplication::notify (this=0x7fffffffd8a0, receiver=0x93296b0, e=0xe6653a0)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qapplication.cpp:3706
#42 0x00007ffff7773c2b in KisApplication::notify (this=0x7fffffffd8a0, receiver=0x93296b0, event=0xe6653a0) at /home/frederik/dev/kde/krita/libs/ui/KisApplication.cpp:519
#43 0x00007fffee5162ad in QCoreApplication::notifyInternal2 (receiver=0x93296b0, event=0xe6653a0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:988
#44 0x00007fffee51ac38 in QCoreApplication::sendEvent (receiver=0x93296b0, event=0xe6653a0)
    at ../../include/QtCore/../../../../qt-src-dev/qtbase/src/corelib/kernel/qcoreapplication.h:231
#45 0x00007fffee51773d in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0xa680f0)
---Type <return> to continue, or q <return> to quit---
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1648
#46 0x00007fffee516bcf in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1502
#47 0x00007fffee5a81ce in postEventSourceDispatch (s=0xbeb050) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:276
#48 0x00007fffe82bb587 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#49 0x00007fffe82bb7f0 in ?? () from /usr/lib/libglib-2.0.so.0
#50 0x00007fffe82bb89c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#51 0x00007fffee5a7674 in QEventDispatcherGlib::processEvents (this=0xbf0db0, flags=...) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:423
#52 0x00007fffe4d770bd in QPAEventDispatcherGlib::processEvents (this=0xbf0db0, flags=...)
    at /home/frederik/dev/qt/qt-src-dev/qtbase/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp:121
#53 0x00007fffee5117b4 in QEventLoop::processEvents (this=0x7fffffffd780, flags=...) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qeventloop.cpp:134
#54 0x00007fffee5119cb in QEventLoop::exec (this=0x7fffffffd780, flags=...) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qeventloop.cpp:212
#55 0x00007fffee516a98 in QCoreApplication::exec () at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1261
#56 0x00007fffee97da46 in QGuiApplication::exec () at /home/frederik/dev/qt/qt-src-dev/qtbase/src/gui/kernel/qguiapplication.cpp:1657
#57 0x00007fffef052659 in QApplication::exec () at /home/frederik/dev/qt/qt-src-dev/qtbase/src/widgets/kernel/qapplication.cpp:2919
#58 0x0000000000408e88 in main (argc=1, argv=0x7fffffffdf38) at /home/frederik/dev/kde/krita/krita/main.cc:258
(gdb) frame 4
#4  0x00007fffee23ae12 in qt_assert (assertion=0x7ffff636a5d0 "!thumbnail.isNull() || m_paintDevice->extent().isEmpty()", 
    file=0x7ffff636a588 "/home/frederik/dev/kde/krita/libs/image/kis_paint_device_cache.h", line=104) at /home/frederik/dev/qt/qt-src-dev/qtbase/src/corelib/global/qglobal.cpp:3064
3064        qFatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line);
(gdb) print Quit
(gdb) frame 5
#5  0x00007ffff620c069 in KisPaintDeviceCache::createThumbnail (this=0xa59a6e8, w=20, h=0, oversample=1, renderingIntent=KoColorConversionTransformation::IntentPerceptual, 
    conversionFlags=...) at /home/frederik/dev/kde/krita/libs/image/kis_paint_device_cache.h:104
104             Q_ASSERT(!thumbnail.isNull() || m_paintDevice->extent().isEmpty());
(gdb) print thumbnail
$1 = {<QPaintDevice> = {_vptr$QPaintDevice = 0x7fffeeeb9790 <vtable for QImage+16>, painters = 0, reserved = 0x0}, d = 0x0}
(gdb) print thumbnail.isNull()
[Thread 0x7fffd373f700 (LWP 22436) exited]
[Thread 0x7fffd273d700 (LWP 22434) exited]
[Thread 0x7fffd2f3e700 (LWP 22437) exited]
[Thread 0x7fffcaf3e700 (LWP 22435) exited]
$2 = true
(gdb) print m_paintDevice->extent().isEmpty()
$3 = false
(gdb) print m_paintDevice->extent()
$4 = {x1 = 0, y1 = 1408, x2 = 3135, y2 = 1471}
(gdb) frame 12
#12 0x00007ffff778ab68 in KisNodeDelegate::paint (this=0x9d8c630, p=0x7fffffff9540, o=..., index=...) at /home/frederik/dev/kde/krita/libs/ui/KisNodeDelegate.cpp:112
112             drawThumbnail(p, option, index);
(gdb) print index
$5 = (const QModelIndex &) @0x7fffffff9088: {r = 1, c = 0, i = 165284592, m = 0x9d93c70}
(gdb) frame 11
#11 0x00007ffff778c00a in KisNodeDelegate::drawThumbnail (this=0x9d8c630, p=0x7fffffff9540, option=..., index=...) at /home/frederik/dev/kde/krita/libs/ui/KisNodeDelegate.cpp:274
274         QImage img = index.data(int(KisNodeModel::BeginThumbnailRole) + thumbSize).value<QImage>();
(gdb) print thumbSize
$6 = 20
(gdb) print index
$7 = (const QModelIndex &) @0x7fffffff9088: {r = 1, c = 0, i = 165284592, m = 0x9d93c70}
(gdb) print index.data 
$8 = {QVariant (const QModelIndex * const, int)} 0x7ffff74d1722 <QModelIndex::data(int) const>
(gdb) frame 7 
#7  0x00007ffff61ba6de in KisLayer::createThumbnail (this=0xa3e63e0, w=20, h=0) at /home/frederik/dev/kde/krita/libs/image/kis_layer.cc:794
warning: Source file is more recent than executable.
794                                                KoColorConversionTransformation::internalConversionFlags()) : QImage();
(gdb) print node
No symbol "node" in current context.
(gdb) frame 8
#8  0x00007ffff7543ce9 in KisNodeModel::data (this=0x9d93a40, index=..., role=120) at /home/frederik/dev/kde/krita/libs/ui/kis_node_model.cpp:480
480                 return node->createThumbnail(size.width(), size.height());
(gdb) print node
$9 = {d = 0xa3e63e0}
(gdb) print node->extent()
$10 = {x1 = 0, y1 = 1408, x2 = 3135, y2 = 1471}
(gdb) print maxSize
$11 = 20
(gdb) 


So basically we'd like a thumbnail for size: 3135 x (1471-1408) -> 3135 x 63 with maxSize 20, which turns out to be QSize 20x0.

QSize size = node->extent().size();
size.scale(maxSize, maxSize, Qt::KeepAspectRatio);
return node->createThumbnail(size.width(), size.height());

then createThumbnail asserts since it creates a null image thumbnail (height 0) for a layer that is not empty.
Comment 1 Dmitry Kazakov 2016-11-08 14:38:18 UTC
Git commit e4d1b7c6795658512f0122f4e4201a4d77a20694 by Dmitry Kazakov.
Committed on 08/11/2016 at 14:37.
Pushed by dkazakov into branch 'krita/3.1'.

Fix assert in Thumbnail Cache

Limit the size of the thumbnail by 1px to get sane results

M  +36   -15   libs/image/kis_paint_device.cc
M  +0    -1    libs/image/kis_paint_device_cache.h

http://commits.kde.org/krita/e4d1b7c6795658512f0122f4e4201a4d77a20694
Comment 2 Dmitry Kazakov 2016-11-09 11:00:04 UTC
Git commit e7a1e787d060b6407fce6dc344e5cdb13d9f55fc by Dmitry Kazakov.
Committed on 09/11/2016 at 10:29.
Pushed by dkazakov into branch 'rempt/impex-refactoring'.

Fix assert in Thumbnail Cache

Limit the size of the thumbnail by 1px to get sane results

M  +36   -15   libs/image/kis_paint_device.cc
M  +0    -1    libs/image/kis_paint_device_cache.h

http://commits.kde.org/krita/e7a1e787d060b6407fce6dc344e5cdb13d9f55fc