Bug 339921 - TestGraphicsView crashes with any sheet as input
Summary: TestGraphicsView crashes with any sheet as input
Status: RESOLVED FIXED
Alias: None
Product: calligrasheets
Classification: Applications
Component: general (show other bugs)
Version: 2.8.5
Platform: Debian testing Linux
: NOR crash
Target Milestone: ---
Assignee: Calligra Sheets (KSpread) Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-13 08:13 UTC by Philip Van Hoof
Modified: 2014-10-17 13:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Sample that I used to test with (9.00 KB, application/vnd.ms-excel.12)
2014-10-13 08:14 UTC, Philip Van Hoof
Details
PixmapCacheSheetView doesn't work correctm use SheetView for CanvasItem instead (884 bytes, text/plain)
2014-10-16 19:05 UTC, Philip Van Hoof
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Van Hoof 2014-10-13 08:13:19 UTC
The TestGraphicsView.cpp test fails and crashes in any/most documents that I try. When I open the documents with calligrasheets in /usr/bin it works fine.

Reproducible: Always

Steps to Reproduce:
1. Change the KUrl to point to Book1.xlsx in sheets/tests/TestGraphicsView.cpp
2. cd _build/sheets/tests
3. make TestGraphicsView
4. gdb ./TestGraphicsView
5. (gdb) run



Actual Results:  
Starting program: /data/repos/vanerum/calligra-2.8.5+dfsg/obj-i486-linux-gnu/sheets/tests/./TestGraphicsView 
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1".
Legacy integer arithmetics implementation 
QGraphicsWidget::setAttribute: unsupported attribute 5
QGraphicsWidget::setAttribute: unsupported attribute 14
QGraphicsWidget::setAttribute: unsupported attribute 5
QGraphicsWidget::setAttribute: unsupported attribute 5

Program received signal SIGSEGV, Segmentation fault.
0xb71855a1 in QPixmap::pixmapData (this=0x86e0d88) at image/qpixmap.cpp:2161
2161	image/qpixmap.cpp: No such file or directory.
(gdb) thread apply all bt

Thread 1 (Thread 0xb3ff6800 (LWP 2838)):
#0  0xb71855a1 in QPixmap::pixmapData (this=0x86e0d88) at image/qpixmap.cpp:2161
#1  0xb729aae1 in QRasterPaintEngine::drawPixmap (this=0x86fbce0, r=..., pixmap=..., sr=...) at painting/qpaintengine_raster.cpp:2085
#2  0xb7219086 in QPainter::drawPixmap (this=0xbfffe18c, r=..., pm=..., sr=...) at painting/qpainter.cpp:5468
#3  0xb7f66acc in Calligra::Sheets::PixmapCachingSheetView::paintCells (this=0x868e738, painter=..., paintRect=..., topLeft=..., canvas=0x8217280, 
    visibleRect=...) at /data/repos/vanerum/calligra-2.8.5+dfsg/sheets/ui/PixmapCachingSheetView.cpp:240
#4  0xb7eed878 in Calligra::Sheets::CanvasBase::paint (this=this@entry=0x8217280, painter=painter@entry=0xbfffe18c, painterRect=...)
    at /data/repos/vanerum/calligra-2.8.5+dfsg/sheets/part/CanvasBase.cpp:483
#5  0xb7ef1761 in Calligra::Sheets::CanvasItem::paint (this=0x8217268, painter=0xbfffe18c, option=0x86e4e10, widget=0x868fec8)
    at /data/repos/vanerum/calligra-2.8.5+dfsg/sheets/part/CanvasItem.cpp:220
#6  0xb771c0b6 in _q_paintItem (item=item@entry=0x0, painter=0xbfffe18c, painter@entry=0x8217270, option=0x86e4e10, widget=0x868fec8, useWindowOpacity=true, 
    painterStateProtection=true) at graphicsview/qgraphicsscene.cpp:4335
#7  0xb772f23c in QGraphicsScenePrivate::drawItemHelper (this=0x86e4cc0, item=0x8217270, painter=0xbfffe18c, option=0x86e4e10, widget=0x868fec8, 
    painterStateProtection=true) at graphicsview/qgraphicsscene.cpp:4431
#8  0xb7731d96 in QGraphicsScenePrivate::draw (this=0x86e4cc0, item=0x8217270, painter=0xbfffe18c, viewTransform=0xbfffe218, transformPtr=0xbfffded8, 
    exposedRegion=0x86fe2ec, widget=0x868fec8, opacity=1, effectTransform=0x0, wasDirtyParentSceneTransform=true, drawItem=true)
    at graphicsview/qgraphicsscene.cpp:4966
#9  0xb77328df in QGraphicsScenePrivate::drawSubtreeRecursive (this=0x86e4cc0, item=0x8217270, painter=0xbfffe18c, viewTransform=0xbfffe218, 
    exposedRegion=0x86fe2ec, widget=0x868fec8, parentOpacity=1, effectTransform=0x0) at graphicsview/qgraphicsscene.cpp:4857
#10 0xb773305a in QGraphicsScenePrivate::drawItems (this=0x86e4cc0, painter=0xbfffe18c, viewTransform=0xbfffe218, exposedRegion=0x86fe2ec, widget=0x868fec8)
    at graphicsview/qgraphicsscene.cpp:4739
#11 0xb7754ce7 in QGraphicsView::paintEvent (this=<optimized out>, event=<optimized out>) at graphicsview/qgraphicsview.cpp:3471
#12 0xb70f88f9 in QWidget::event (this=0xbffff410, event=0xbfffe798) at kernel/qwidget.cpp:8775
#13 0xb750199a in QFrame::event (this=0xbffff410, e=0xbfffe798) at widgets/qframe.cpp:557
#14 0xb759309d in QAbstractScrollArea::viewportEvent (this=0xbffff410, e=0xbfffe798) at widgets/qabstractscrollarea.cpp:1043
#15 0xb77539aa in QGraphicsView::viewportEvent (this=<optimized out>, event=<optimized out>) at graphicsview/qgraphicsview.cpp:2866
#16 0xb7593323 in viewportEvent (event=0xbfffe798, this=<optimized out>) at widgets/qabstractscrollarea_p.h:100
#17 QAbstractScrollAreaFilter::eventFilter (this=0x86e3c00, o=0x868fec8, e=0xbfffe798) at widgets/qabstractscrollarea_p.h:116
#18 0xb6a909c3 in QCoreApplicationPrivate::sendThroughObjectEventFilters (this=0x806d788, receiver=0x868fec8, event=0xbfffe798)
    at kernel/qcoreapplication.cpp:1065
#19 0xb709d498 in QApplicationPrivate::notify_helper (this=0x806d788, receiver=0x868fec8, e=0xbfffe798) at kernel/qapplication.cpp:4566
#20 0xb70a4360 in QApplication::notify (this=0xbffff3c0, receiver=0x868fec8, e=0xbfffe798) at kernel/qapplication.cpp:4356
#21 0xb6a9084a in QCoreApplication::notifyInternal (this=0xbffff3c0, receiver=0x868fec8, event=0xbfffe798) at kernel/qcoreapplication.cpp:955
#22 0xb70f26f7 in sendSpontaneousEvent (event=0x100, receiver=0x868fde8) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234
#23 QWidgetPrivate::drawWidget (this=0x86f9778, pdev=0x82908c8, rgn=..., offset=..., flags=4, sharedPainter=0x0, backingStore=0x868fde8)
---Type <return> to continue, or q <return> to quit---  
    at kernel/qwidget.cpp:5599
#24 0xb70f3226 in QWidgetPrivate::paintSiblingsRecursive (this=0x86fdfa0, pdev=0x82908c8, siblings=..., index=<optimized out>, rgn=..., offset=..., flags=4, 
    sharedPainter=0x0, backingStore=0x868fde8) at kernel/qwidget.cpp:5808
#25 0xb70f308c in QWidgetPrivate::paintSiblingsRecursive (this=0x86fdfa0, pdev=0x82908c8, siblings=..., index=-1073747305, rgn=..., offset=..., flags=4, 
    sharedPainter=0x0, backingStore=0x868fde8) at kernel/qwidget.cpp:5795
#26 0xb70f308c in QWidgetPrivate::paintSiblingsRecursive (this=0x86fdfa0, pdev=0x82908c8, siblings=..., index=-1073746849, rgn=..., offset=..., flags=4, 
    sharedPainter=0x0, backingStore=0x868fde8) at kernel/qwidget.cpp:5795
#27 0xb70f2254 in QWidgetPrivate::drawWidget (this=0x86fdfa0, pdev=0x82908c8, rgn=..., offset=..., flags=5, sharedPainter=0x0, backingStore=0x868fde8)
    at kernel/qwidget.cpp:5652
#28 0xb72e824b in QWidgetBackingStore::sync (this=0x868fde8) at painting/qbackingstore.cpp:1373
#29 0xb72e864b in QWidgetBackingStore::sync (this=0x868fde8, exposedWidget=0xbffff410, exposedRegion=...) at painting/qbackingstore.cpp:1161
#30 0xb70e6327 in QWidgetPrivate::syncBackingStore (this=0x86fdfa0, region=...) at kernel/qwidget.cpp:1903
#31 0xb7117b9f in QETWidget::translatePaintEvent (this=0xbffff410, event=0xbffff05c) at kernel/qapplication_x11.cpp:5260
#32 0xb712603e in QApplication::x11ProcessEvent (this=0xbffff3c0, event=0xbffff05c) at kernel/qapplication_x11.cpp:3563
#33 0xb7150f21 in x11EventSourceDispatch (s=s@entry=0x806fea8, callback=0x0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#34 0xb553e313 in g_main_dispatch (context=0x806ea30, context@entry=0x806fea8) at /build/glib2.0-f_gKLq/glib2.0-2.40.0/./glib/gmain.c:3064
#35 g_main_context_dispatch (context=context@entry=0x806ea30) at /build/glib2.0-f_gKLq/glib2.0-2.40.0/./glib/gmain.c:3663
#36 0xb553e598 in g_main_context_iterate (context=context@entry=0x806ea30, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at /build/glib2.0-f_gKLq/glib2.0-2.40.0/./glib/gmain.c:3734
#37 0xb553e658 in g_main_context_iteration (context=0x806ea30, may_block=1) at /build/glib2.0-f_gKLq/glib2.0-2.40.0/./glib/gmain.c:3795
#38 0xb6ac2ab9 in QEventDispatcherGlib::processEvents (this=0x8057068, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#39 0xb7150ff6 in QGuiEventDispatcherGlib::processEvents (this=0x8057068, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#40 0xb6a8f1cf in QEventLoop::processEvents (this=0xbffff334, flags=...) at kernel/qeventloop.cpp:149
#41 0xb6a8f55e in QEventLoop::exec (this=0xbffff334, flags=...) at kernel/qeventloop.cpp:204
#42 0xb6a956d6 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1227
#43 0xb709b5b4 in QApplication::exec () at kernel/qapplication.cpp:3828
#44 0x080499d2 in main (argc=1, argv=0xbffff504) at /data/repos/vanerum/calligra-2.8.5+dfsg/sheets/tests/TestGraphicsView.cpp:82
(gdb) 


Expected Results:  
No crash
Comment 1 Philip Van Hoof 2014-10-13 08:14:04 UTC
Created attachment 89106 [details]
Sample that I used to test with
Comment 2 Philip Van Hoof 2014-10-13 08:16:45 UTC
Note that this was apt-get source calligra on a Debian Jessie (that's a Calligra 2.8.5 atm) and then a 'dpkg-buildpackage -us -uc' on i586 based architecture. I tried on multiple such machines and also with another user of the CanvasItem QGraphicsView of Sheets. Same unfortunate results.
Comment 3 Philip Van Hoof 2014-10-13 08:28:51 UTC
(gdb) up
#1  0xb729aae1 in QRasterPaintEngine::drawPixmap (this=0x86fbce0, r=..., pixmap=..., sr=...) at painting/qpaintengine_raster.cpp:2085
2085	painting/qpaintengine_raster.cpp: No such file or directory.
(gdb) 
#2  0xb7219086 in QPainter::drawPixmap (this=0xbfffe18c, r=..., pm=..., sr=...) at painting/qpainter.cpp:5468
5468	painting/qpainter.cpp: No such file or directory.
(gdb) 
Some extra information that might be helpful:

#3  0xb7f66acc in Calligra::Sheets::PixmapCachingSheetView::paintCells (this=0x868e738, painter=..., paintRect=..., topLeft=..., canvas=0x8217280, 
    visibleRect=...) at /data/repos/vanerum/calligra-2.8.5+dfsg/sheets/ui/PixmapCachingSheetView.cpp:240
240	                    painter.drawPixmap(r, *p, p->rect());
(gdb) print p
$1 = (QPixmap *) 0x86e0d88
(gdb) print *p
$2 = {<QPaintDevice> = {_vptr.QPaintDevice = 0x0, painters = 0}, data = {d = 0x821b1a8}}
(gdb)
Comment 4 Philip Van Hoof 2014-10-13 08:43:59 UTC
I also just tested with a test.ods created by calligrasheets binary. This also crashes.
Comment 5 Philip Van Hoof 2014-10-13 08:58:27 UTC
Looks like tileCache.insert() doesn't work:

(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /data/repos/vanerum/calligra-2.8.5+dfsg/obj-i486-linux-gnu/sheets/tests/TestGraphicsView 
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1".
Legacy integer arithmetics implementation 
QGraphicsWidget::setAttribute: unsupported attribute 5
QGraphicsWidget::setAttribute: unsupported attribute 14
QGraphicsWidget::setAttribute: unsupported attribute 5
QGraphicsWidget::setAttribute: unsupported attribute 5

Breakpoint 2, Calligra::Sheets::PixmapCachingSheetView::Private::getTile (this=0x8645db0, sheet=0x821fe00, x=0, y=y@entry=0, canvas=0x82400a0)
    at /data/repos/vanerum/calligra-2.8.5+dfsg/sheets/ui/PixmapCachingSheetView.cpp:155
155	    int idx = x << 16 | y;
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0xb71855a1 in QPixmap::pixmapData (this=0x86bb6f0) at image/qpixmap.cpp:2161
2161	image/qpixmap.cpp: No such file or directory.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /data/repos/vanerum/calligra-2.8.5+dfsg/obj-i486-linux-gnu/sheets/tests/TestGraphicsView 
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1".
Legacy integer arithmetics implementation 
QGraphicsWidget::setAttribute: unsupported attribute 5
QGraphicsWidget::setAttribute: unsupported attribute 14
QGraphicsWidget::setAttribute: unsupported attribute 5
QGraphicsWidget::setAttribute: unsupported attribute 5

Breakpoint 2, Calligra::Sheets::PixmapCachingSheetView::Private::getTile (this=0x8646b20, sheet=0x820d060, x=0, y=y@entry=0, canvas=0x824bf20)
    at /data/repos/vanerum/calligra-2.8.5+dfsg/sheets/ui/PixmapCachingSheetView.cpp:155
155	    int idx = x << 16 | y;
(gdb) n
154	{
(gdb) 
156	    if (tileCache.contains(idx)) return tileCache.object(idx);
(gdb) 
155	    int idx = x << 16 | y;
(gdb) 
156	    if (tileCache.contains(idx)) return tileCache.object(idx);
(gdb) 
155	    int idx = x << 16 | y;
(gdb) 
156	    if (tileCache.contains(idx)) return tileCache.object(idx);
(gdb) 
168	    TileDrawingJob job(sheet, q, canvas, lastScale, x, y);
(gdb) 
169	    job.run();
(gdb) 
170	    QPixmap *pm = new QPixmap(QPixmap::fromImage(job.m_image));
(gdb) 
171	    if (tileCache.insert(idx, pm)) {
(gdb) 
170	    QPixmap *pm = new QPixmap(QPixmap::fromImage(job.m_image));
(gdb) 
171	    if (tileCache.insert(idx, pm)) {
(gdb) 
176	    return 0;
(gdb) p tileCache
$10 = {f = 0x86a82c8, l = 0x86a82c8, hash = {{d = 0x8108250, e = 0x8108250}}, unused = 0x0, mx = 128, total = 1}
(gdb)
Comment 6 Philip Van Hoof 2014-10-13 09:12:16 UTC
Never mind Comment #5. I was looking at the wrong place.

This is a break at 241 (line where it happens) and then next until it crashes.

Breakpoint 1, Calligra::Sheets::PixmapCachingSheetView::paintCells (this=0x8650f28, painter=..., paintRect=..., topLeft=..., canvas=0x819a4d8, visibleRect=...)
    at /data/repos/vanerum/calligra-2.8.5+dfsg/sheets/ui/PixmapCachingSheetView.cpp:241
241	                    painter.drawPixmap(r, *p, p->rect());
(gdb) n
236	            for (int y = qMax(0, tiles.top()); y < tiles.bottom(); y++) {
(gdb) 
237	                QPixmap *p = d->getTile(s, x, y, canvas);
(gdb) 
238	                if (p) {
(gdb) 
237	                QPixmap *p = d->getTile(s, x, y, canvas);
(gdb) 
238	                if (p) {
(gdb) 
239	                    QPointF pt(x * TILESIZE / scale.x(), y * TILESIZE / scale.y());
(gdb) 
241	                    painter.drawPixmap(r, *p, p->rect());
(gdb) p x
$1 = <optimized out>
(gdb) p y
$2 = 0
(gdb) n
240	                    QRectF r(pt, QSizeF(TILESIZE / sx, TILESIZE / sy));
(gdb) 
239	                    QPointF pt(x * TILESIZE / scale.x(), y * TILESIZE / scale.y());
(gdb) 
240	                    QRectF r(pt, QSizeF(TILESIZE / sx, TILESIZE / sy));
(gdb) 
241	                    painter.drawPixmap(r, *p, p->rect());
(gdb) 
650	inline QRectF::QRectF(const QRect &r)
(gdb) 
241	                    painter.drawPixmap(r, *p, p->rect());
(gdb) 
650	inline QRectF::QRectF(const QRect &r)
(gdb) 
241	                    painter.drawPixmap(r, *p, p->rect());
(gdb) 

Program received signal SIGSEGV, Segmentation fault.
0xb71855a1 in QPixmap::pixmapData (this=0x86a8218) at image/qpixmap.cpp:2161
2161	image/qpixmap.cpp: No such file or directory.
(gdb)
Comment 7 Philip Van Hoof 2014-10-16 19:05:30 UTC
Created attachment 89164 [details]
PixmapCacheSheetView doesn't work correctm use SheetView for CanvasItem instead

This fixes it for me
Comment 8 Halla Rempt 2014-10-17 13:29:34 UTC
Git commit f96a6f8291ade5f93d5e6e8b2c530964f251125b by Boudewijn Rempt.
Committed on 17/10/2014 at 13:20.
Pushed by rempt into branch 'master'.

The PixmapCacheSheetView crashes after the getTile API returns from the QCache, the QImage, but its use is deprecated

More on the bug and crash explained here:

https://bugs.kde.org/show_bug.cgi?id=339921

I think it's better to just stop using PixmapCacheSheetView and simply use SheetView directly in CanvasItem.

CCMAIL:me@pvanhoof.be

M  +2    -2    sheets/part/CanvasItem.cpp

http://commits.kde.org/calligra/f96a6f8291ade5f93d5e6e8b2c530964f251125b