Bug 297262

Summary: Gwenview crashes when reloading a .png that, when reloading, happens to be empty. [Gwenview::Document::loadingState, Gwenview::RasterImageView::loadFromDocument ]
Product: [Applications] gwenview Reporter: Tor Bellino <ariel>
Component: generalAssignee: Gwenview Bugs <gwenview-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: ab.kde, basinilya, benni, linux776, manuel.neumann, moraru69, solix4321, susundberg, webcoach101
Priority: NOR    
Version: 2.8.1   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 4.10
Attachments: New crash information added by DrKonqi

Description Tor Bellino 2012-04-01 20:04:44 UTC
Application: gwenview (2.8.1)
KDE Platform Version: 4.8.1 (4.8.1)
Qt Version: 4.8.0
Operating System: Linux 3.2.0-20-generic-pae i686
Distribution: Ubuntu precise (development branch)

-- Information about the crash:
- What I was doing when the application crashed:

Doing some calculations in Octave and plotting them in a .png file. I had the image open, run the Octave routine again (overwrites the file) and accidentally pressed F5 while Octave hadn't finished working. Then Gwenview crashed.

The bug can be reproduced by opening a .png file, emptying it, and pressing F5 in Gwenview to reload the image. It crashes.

It doesn't crash if an empty .png file is opened directly, not refreshing.

The crash can be reproduced every time.

-- Backtrace:
Application: Gwenview (gwenview), signal: Segmentation fault
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0xb439f980 (LWP 4498))]

Thread 4 (Thread 0xb1e5eb40 (LWP 4500)):
#0  0xb5076480 in __i686.get_pc_thunk.bx () from /lib/i386-linux-gnu/libpthread.so.0
#1  0xb5079cbf in pthread_mutex_lock () from /lib/i386-linux-gnu/libpthread.so.0
#2  0xb5b155f4 in pthread_mutex_lock () from /lib/i386-linux-gnu/libc.so.6
#3  0xb4fef3e0 in g_mutex_lock () from /lib/i386-linux-gnu/libglib-2.0.so.0
#4  0xb4fafa75 in g_main_context_check () from /lib/i386-linux-gnu/libglib-2.0.so.0
#5  0xb4fb0002 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#6  0xb4fb01c1 in g_main_context_iteration () from /lib/i386-linux-gnu/libglib-2.0.so.0
#7  0xb7133067 in QEventDispatcherGlib::processEvents (this=0xb1500468, flags=...) at kernel/qeventdispatcher_glib.cpp:426
#8  0xb70fec8d in QEventLoop::processEvents (this=0xb1e5e240, flags=...) at kernel/qeventloop.cpp:149
#9  0xb70fef29 in QEventLoop::exec (this=0xb1e5e240, flags=...) at kernel/qeventloop.cpp:204
#10 0xb6fe894c in QThread::exec (this=0x9d73510) at thread/qthread.cpp:501
#11 0xb70dc2dd in QInotifyFileSystemWatcherEngine::run (this=0x9d73510) at io/qfilesystemwatcher_inotify.cpp:248
#12 0xb6febde0 in QThreadPrivate::start (arg=0x9d73510) at thread/qthread_unix.cpp:298
#13 0xb5077d4c in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#14 0xb5b07ace in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 3 (Thread 0xb11dab40 (LWP 4505)):
#0  0xb5065dcd in clock_gettime () from /lib/i386-linux-gnu/librt.so.1
#1  0xb7049da5 in do_gettime (frac=0xb11d9fb0, sec=0xb11d9fa8) at tools/qelapsedtimer_unix.cpp:123
#2  qt_gettime () at tools/qelapsedtimer_unix.cpp:140
#3  0xb71339a6 in QTimerInfoList::updateCurrentTime (this=0xb0802074) at kernel/qeventdispatcher_unix.cpp:343
#4  0xb7133cfa in QTimerInfoList::timerWait (this=0xb0802074, tm=...) at kernel/qeventdispatcher_unix.cpp:450
#5  0xb71325a3 in timerSourcePrepareHelper (src=<optimized out>, timeout=0xb11da0bc) at kernel/qeventdispatcher_glib.cpp:136
#6  0xb713263d in timerSourcePrepare (source=0xb0802040, timeout=<optimized out>) at kernel/qeventdispatcher_glib.cpp:169
#7  0xb4faf762 in g_main_context_prepare () from /lib/i386-linux-gnu/libglib-2.0.so.0
#8  0xb4faff6f in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#9  0xb4fb01c1 in g_main_context_iteration () from /lib/i386-linux-gnu/libglib-2.0.so.0
#10 0xb7133067 in QEventDispatcherGlib::processEvents (this=0xb0800468, flags=...) at kernel/qeventdispatcher_glib.cpp:426
#11 0xb70fec8d in QEventLoop::processEvents (this=0xb11da240, flags=...) at kernel/qeventloop.cpp:149
#12 0xb70fef29 in QEventLoop::exec (this=0xb11da240, flags=...) at kernel/qeventloop.cpp:204
#13 0xb6fe894c in QThread::exec (this=0x9fa90f0) at thread/qthread.cpp:501
#14 0xb70dc2dd in QInotifyFileSystemWatcherEngine::run (this=0x9fa90f0) at io/qfilesystemwatcher_inotify.cpp:248
#15 0xb6febde0 in QThreadPrivate::start (arg=0x9fa90f0) at thread/qthread_unix.cpp:298
#16 0xb5077d4c in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#17 0xb5b07ace in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 2 (Thread 0xaeea6b40 (LWP 4511)):
#0  0xb76f7424 in __kernel_vsyscall ()
#1  0xb507b96b in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/i386-linux-gnu/libpthread.so.0
#2  0xb5b153dc in pthread_cond_wait () from /lib/i386-linux-gnu/libc.so.6
#3  0xb6fec350 in wait (time=4294967295, this=0x9d24228) at thread/qwaitcondition_unix.cpp:86
#4  QWaitCondition::wait (this=0x9d0d980, mutex=0x9d0d97c, time=4294967295) at thread/qwaitcondition_unix.cpp:158
#5  0xb760a70b in Gwenview::SemanticInfoThread::run (this=0x9d0d970) at ../../lib/semanticinfo/nepomuksemanticinfobackend.cpp:145
#6  0xb6febde0 in QThreadPrivate::start (arg=0x9d0d970) at thread/qthread_unix.cpp:298
#7  0xb5077d4c in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#8  0xb5b07ace in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 1 (Thread 0xb439f980 (LWP 4498)):
[KCrash Handler]
#7  0xb75921f7 in Gwenview::Document::loadingState (this=0x0) at ../../lib/document/document.cpp:162
#8  0xb75ac81b in Gwenview::RasterImageView::loadFromDocument (this=0xa1262e0) at ../../lib/documentview/rasterimageview.cpp:196
#9  0xb759fc32 in Gwenview::AbstractImageView::setDocument (this=0xa1262e0, doc=...) at ../../lib/documentview/abstractimageview.cpp:140
#10 0xb75ae46a in Gwenview::RasterImageViewAdapter::slotLoadingFailed (this=0xa126308) at ../../lib/documentview/rasterimageviewadapter.cpp:118
#11 0xb75ae4cb in qt_static_metacall (_id=0, _o=0xa126308, _c=<optimized out>, _a=<optimized out>) at ./rasterimageviewadapter.moc:50
#12 Gwenview::RasterImageViewAdapter::qt_static_metacall (_o=0xa126308, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0xbf86a408) at ./rasterimageviewadapter.moc:44
#13 0xb7116e31 in QMetaObject::activate (sender=0xa0f8bb0, m=0xb7634e78, local_signal_index=5, argv=0xbf86a408) at kernel/qobject.cpp:3547
#14 0xb7591fe5 in Gwenview::Document::loadingFailed (this=0xa0f8bb0, _t1=...) at ./document.moc:179
#15 0xb75928c5 in Gwenview::Document::emitLoadingFailed (this=0xa0f8bb0) at ../../lib/document/document.cpp:408
#16 0xb7592e98 in qt_static_metacall (_a=0xbf86a4e0, _id=14, _o=0xa0f8bb0, _c=<optimized out>) at ./document.moc:91
#17 Gwenview::Document::qt_static_metacall (_o=0xa0f8bb0, _c=QMetaObject::InvokeMetaMethod, _id=14, _a=0xbf86a4e0) at ./document.moc:71
#18 0xb7116e31 in QMetaObject::activate (sender=0xa585540, m=0xb7634ac0, local_signal_index=3, argv=0x0) at kernel/qobject.cpp:3547
#19 0xb7590345 in Gwenview::AbstractDocumentImpl::loadingFailed (this=0xa585540) at ./abstractdocumentimpl.moc:129
#20 0xb75985a4 in Gwenview::LoadingDocumentImpl::slotMetaInfoLoaded (this=0xa585540) at ../../lib/document/loadingdocumentimpl.cpp:394
#21 0xb7116e31 in QMetaObject::activate (sender=0xa102d18, m=0xb725d820, local_signal_index=1, argv=0x0) at kernel/qobject.cpp:3547
#22 0xb71660a5 in QFutureWatcherBase::finished (this=0xa102d18) at .moc/release-shared/moc_qfuturewatcher.cpp:141
#23 0xb6fda9fc in QFutureWatcherBasePrivate::sendCallOutEvent (this=0xa3359c8, event=0xafe02258) at concurrent/qfuturewatcher.cpp:439
#24 0xb6fdad02 in QFutureWatcherBase::event (this=0xa102d18, event=0xafe02258) at concurrent/qfuturewatcher.cpp:344
#25 0xb60afd24 in notify_helper (e=0xafe02258, receiver=0xa102d18, this=0x9c09f68) at kernel/qapplication.cpp:4555
#26 QApplicationPrivate::notify_helper (this=0x9c09f68, receiver=0xa102d18, e=0xafe02258) at kernel/qapplication.cpp:4527
#27 0xb60b515d in QApplication::notify (this=0xafe02258, receiver=0xa102d18, e=0xafe02258) at kernel/qapplication.cpp:4284
#28 0xb6c32801 in KApplication::notify (this=0xbf86ae18, receiver=0xa102d18, event=0xafe02258) at ../../kdeui/kernel/kapplication.cpp:311
#29 0xb71000fe in QCoreApplication::notifyInternal (this=0xbf86ae18, receiver=0xa102d18, event=0xafe02258) at kernel/qcoreapplication.cpp:876
#30 0xb7104258 in sendEvent (event=<optimized out>, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#31 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x9be8a40) at kernel/qcoreapplication.cpp:1500
#32 0xb710458c in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1393
#33 0xb7132c14 in sendPostedEvents () at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236
#34 postEventSourceDispatch (s=0x9c091f8) at kernel/qeventdispatcher_glib.cpp:279
#35 0xb4fafcda in g_main_context_dispatch () from /lib/i386-linux-gnu/libglib-2.0.so.0
#36 0xb4fb00e5 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#37 0xb4fb01c1 in g_main_context_iteration () from /lib/i386-linux-gnu/libglib-2.0.so.0
#38 0xb7133007 in QEventDispatcherGlib::processEvents (this=0x9be95a8, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#39 0xb616889a in QGuiEventDispatcherGlib::processEvents (this=0x9be95a8, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#40 0xb70fec8d in QEventLoop::processEvents (this=0xbf86ad64, flags=...) at kernel/qeventloop.cpp:149
#41 0xb70fef29 in QEventLoop::exec (this=0xbf86ad64, flags=...) at kernel/qeventloop.cpp:204
#42 0xb710463a in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1148
#43 0xb60ad8c4 in QApplication::exec () at kernel/qapplication.cpp:3816
#44 0x080661ad in main (argc=0, argv=0x0) at ../../app/main.cpp:142

Reported using DrKonqi
Comment 1 Jekyll Wu 2012-10-06 17:35:19 UTC
*** Bug 307982 has been marked as a duplicate of this bug. ***
Comment 2 Jekyll Wu 2012-10-19 13:01:53 UTC
*** Bug 308640 has been marked as a duplicate of this bug. ***
Comment 3 Jekyll Wu 2012-10-28 09:55:10 UTC
*** Bug 309127 has been marked as a duplicate of this bug. ***
Comment 4 Lilian A. Moraru 2012-10-28 10:13:06 UTC
Here is a tar with 4 photos from which 1 is broken to test on: https://files.one.ubuntu.com/MRl8rEpUSMiqEIUZ2Rrkvw
Comment 5 Manuel 2012-11-13 11:37:13 UTC
Created attachment 75215 [details]
New crash information added by DrKonqi

gwenview (2.8.5) on KDE Platform 4.8.5 (4.8.5) "release 2" using Qt 4.8.1

- What I was doing when the application crashed:

Updating an png file with an external editor while having gwenview open in the same directory.

-- Backtrace (Reduced):
#6  Gwenview::Document::loadingState (this=0x0) at /usr/src/debug/gwenview-4.8.5/lib/document/document.cpp:162
#7  0x00007f95d8edf166 in Gwenview::RasterImageView::loadFromDocument (this=0x868650) at /usr/src/debug/gwenview-4.8.5/lib/documentview/rasterimageview.cpp:196
#8  0x00007f95d8ed4519 in Gwenview::AbstractImageView::setDocument (this=0x868650, doc=...) at /usr/src/debug/gwenview-4.8.5/lib/documentview/abstractimageview.cpp:142
#9  0x00007f95d8ee08f3 in Gwenview::RasterImageViewAdapter::slotLoadingFailed (this=<optimized out>) at /usr/src/debug/gwenview-4.8.5/lib/documentview/rasterimageviewadapter.cpp:118
[...]
#11 0x00007f95d8ec8095 in Gwenview::Document::loadingFailed (this=<optimized out>, _t1=...) at /usr/src/debug/gwenview-4.8.5/build/lib/document.moc:179
Comment 6 Benni Hill 2012-12-08 19:08:52 UTC
https://git.reviewboard.kde.org/r/107636/
Comment 7 Aurelien Gateau 2012-12-10 16:53:16 UTC
*** Bug 306013 has been marked as a duplicate of this bug. ***
Comment 8 Benni Hill 2012-12-10 19:26:10 UTC
Git commit a105634dd43c626cf1841203650b97b6faf69910 by Benjamin Löwe.
Committed on 10/12/2012 at 20:20.
Pushed by bennihill into branch 'master'.

Fix for bug 297262 - Gwenview crashes when reloading a .png that,
when reloading, happens to be empty.
REVIEW: 107636
FIXED-IN: 4.10

M  +3    -1    lib/documentview/abstractimageview.cpp
M  +10   -8    lib/documentview/rasterimageview.cpp
M  +15   -12   lib/documentview/svgviewadapter.cpp

http://commits.kde.org/gwenview/a105634dd43c626cf1841203650b97b6faf69910
Comment 9 Benni Hill 2012-12-23 16:23:03 UTC
*** Bug 312077 has been marked as a duplicate of this bug. ***
Comment 10 Ilya Basin 2012-12-30 11:39:23 UTC
Cherry-picked the fix into KDE/4.9 (too much to compile to install 4.10)
It still crashes at:
    void ViewMainPage::reload()
    {
        Document::Ptr doc = d->currentView()->document();
because d->currentView() returns NULL
Comment 11 Benni Hill 2012-12-30 15:50:45 UTC
Could you explain how to reproduce the crash?

I opened a png file, overwrote it with an empty file and hit reload. But it didn't crash. (Branch KDE/4.9 with commit a105634dd43c626cf1841203650b97b6faf69910 applied.)
Comment 12 Ilya Basin 2012-12-30 16:38:50 UTC
Benny Hill, please look at #306013 . It was marked as a duplicate of this bug, but perhaps it's not.
In my case, gwenview crashes when I click a folder without images in the folder tree sidebar
Comment 13 Ilya Basin 2012-12-30 16:39:26 UTC
Benny Hill, please look at #306013 . It was marked as a duplicate of this bug, but perhaps it's not.
In my case, gwenview crashes when I click a folder without images in the folder tree sidebar and press F5
Comment 14 Benni Hill 2012-12-31 02:33:22 UTC
Thanks a lot. I could reproduce the crash and your diagnosis was right.

I reopened bug #306013 and am closing this one again.
You can find my proposed patch here:
https://git.reviewboard.kde.org/r/108042/
Comment 15 Benni Hill 2013-04-11 15:07:03 UTC
*** Bug 318112 has been marked as a duplicate of this bug. ***