Bug 192191 - Segfault of kded caused by tga handler
Summary: Segfault of kded caused by tga handler
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kimgio (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-10 03:44 UTC by LuRan
Modified: 2009-05-26 17:54 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
backtrace of the crash (4.51 KB, application/octet-stream)
2009-05-10 03:45 UTC, LuRan
Details
faviicons (476.47 KB, application/x-bzip-compressed-tar)
2009-05-12 04:11 UTC, LuRan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description LuRan 2009-05-10 03:44:36 UTC
Version:           svn snapshot (using Devel)
Compiler:          gcc 4.4 
OS:                Linux
Installed from:    Compiled sources

Kded crashes constantly after the latest tga.cpp update in svn. It looks like the lastest change causes some files being misidentified as tga file and kded crashed when trying to read them.
Comment 1 LuRan 2009-05-10 03:45:24 UTC
Created attachment 33506 [details]
backtrace of the crash
Comment 2 LuRan 2009-05-10 03:47:10 UTC
After revert 963718 the crash disappears
Comment 3 Aaron J. Seigo 2009-05-10 04:06:29 UTC
backtrace:

#6  0xb30420a9 in LoadTGA (s=@0xbfbf2e50, tga=@0xbfbf2e6c, img=@0xbfbf2e80) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kimgio/tga.cpp:299
#7  0xb3042799 in TGAHandler::read (this=0x8c16c60, outImage=0xbfbf2fb4) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kimgio/tga.cpp:355
#8  0xb7016e74 in QImageReader::read () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtGui.so.4
#9  0xb701721a in QImageReader::read () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtGui.so.4
#10 0xb3be4309 in FavIconsModule::slotResult (this=0x8bd2ef0, job=0x8be47f0) at /home/hooey/vcs/kdesvn/kde4/kdebase/apps/lib/konq/favicons/favicons.cpp:260
#11 0xb3be6387 in FavIconsModule::qt_metacall (this=0x8bd2ef0, _c=QMetaObject::InvokeMetaMethod, _id=6, _a=0xbfbf3278)
    at /home/hooey/vcs/kdesvn/kde4/kdebase/build/apps/lib/konq/favicons/favicons.moc:95
#12 0xb76df800 in QMetaObject::activate () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#13 0xb76dfb33 in QMetaObject::activate () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#14 0xb787b6c4 in KJob::result (this=0x8be47f0, _t1=0x8be47f0) at /home/hooey/vcs/kdesvn/kde4/kdelibs/build/kdecore/kjob.moc:188
#15 0xb787bb6a in KJob::emitResult (this=0x8be47f0) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kdecore/jobs/kjob.cpp:304
#16 0xb7ebe3f0 in KIO::SimpleJob::slotFinished (this=0x8be47f0) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kio/kio/job.cpp:485
#17 0xb7ebe91b in KIO::TransferJob::slotFinished (this=0x8be47f0) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kio/kio/job.cpp:962
#18 0xb7ebc06b in KIO::TransferJob::qt_metacall (this=0x8be47f0, _c=QMetaObject::InvokeMetaMethod, _id=47, _a=0xbfbf34dc) at /home/hooey/vcs/kdesvn/kde4/kdelibs/build/kio/jobclasses.moc:343
#19 0xb76df800 in QMetaObject::activate () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#20 0xb76dfb33 in QMetaObject::activate () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#21 0xb7f8cca8 in KIO::SlaveInterface::finished (this=0x8be63b8) at /home/hooey/vcs/kdesvn/kde4/kdelibs/build/kio/slaveinterface.moc:165
#22 0xb7f90b55 in KIO::SlaveInterface::dispatch (this=0x8be63b8, _cmd=104, rawdata=@0xbfbf3678) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kio/kio/slaveinterface.cpp:175
#23 0xb7f8d164 in KIO::SlaveInterface::dispatch (this=0x8be63b8) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kio/kio/slaveinterface.cpp:91
#24 0xb7f7ed4b in KIO::Slave::gotInput (this=0x8be63b8) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kio/kio/slave.cpp:322
#25 0xb7f811cb in KIO::Slave::qt_metacall (this=0x8be63b8, _c=QMetaObject::InvokeMetaMethod, _id=30, _a=0xbfbf37cc) at /home/hooey/vcs/kdesvn/kde4/kdelibs/build/kio/slave.moc:76
#26 0xb76df800 in QMetaObject::activate () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#27 0xb76dfb33 in QMetaObject::activate () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#28 0xb7e84a58 in KIO::Connection::readyRead (this=0x8be5de0) at /home/hooey/vcs/kdesvn/kde4/kdelibs/build/kio/connection.moc:86
#29 0xb7e86879 in KIO::ConnectionPrivate::dequeue (this=0x8be55c0) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kio/kio/connection.cpp:82
#30 0xb7e869be in KIO::Connection::qt_metacall (this=0x8be5de0, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0x8bc4070) at /home/hooey/vcs/kdesvn/kde4/kdelibs/build/kio/connection.moc:73
#31 0xb76dc0ae in QMetaCallEvent::placeMetaCall () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#32 0xb76df01a in QObject::event () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#33 0xb6f97f2b in QApplicationPrivate::notify_helper () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtGui.so.4
#34 0xb6f98f84 in QApplication::notify () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtGui.so.4
#35 0xb7be282b in KApplication::notify (this=0xbfbf3fa0, receiver=0x8be5de0, event=0x8c678d0) at /home/hooey/vcs/kdesvn/kde4/kdelibs/kdeui/kernel/kapplication.cpp:307
#36 0xb76d23be in QCoreApplication::notifyInternal () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#37 0xb76d270a in QCoreApplicationPrivate::sendPostedEvents () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#38 0xb76d2877 in QCoreApplication::sendPostedEvents () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#39 0xb76eed71 in postEventSourceDispatch () from /home/hooey/vcs/kdesvn/kde4/qt-copy/lib/libQtCore.so.4
#40 0xb68131d8 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#41 0xb6816873 in ?? () from /usr/lib/libglib-2.0.so.0
#42 0x089d00a0 in ?? ()
#43 0x00000000 in ?? ()

(please paste backtraces into the comments, rather than uploading them as attachments)
Comment 4 Aaron J. Seigo 2009-05-10 04:08:50 UTC
also, would it be possible to provide an example of a tga file that triggers this crash? if you can't upload it due to copyright or other content issues, feel free to email it directly.
Comment 5 LuRan 2009-05-10 05:01:34 UTC
Honestly I do not know exactly which files trigger this bug, I noticed this bug because it happens very often (but randomly) on my machine. Usually after I have konqueror or kontact opened for a while, suddenly the program is unresponsible and kded takes 100% cpu, sometimes it will survive after a while but sometimes it will gives segfault. I am pretty busy these days, but when I have some free time I will add some kDebug to tga.cpp ,watch the output and find the troublesome file. Or these are some easier ways to debug this which I do not know?
Comment 6 Aaron J. Seigo 2009-05-10 08:38:36 UTC
i would think that one easy way to find the file that triggers this behaviour is to copy the tga files you have into one folder, view that folder with dolphin while doing a "manual" binary search: divide out half the files into a different dir; if the crash doesn't happen, move to the other dir, if it does, divide the current dir in half, etc, etc. this should get you to the troublesome file(s) in short order.
Comment 7 Pino Toscano 2009-05-10 10:30:45 UTC
Aurelien, could you please take a look at this?
Comment 8 LuRan 2009-05-10 13:57:59 UTC
The weird thing is that I do not have any tga file, actually I never heard of tga file until I encountered this bug. So I guess some of my files are misidentified as tga files.
Comment 9 Aurelien Gateau 2009-05-11 22:52:39 UTC
It seems to be crashing while parsing favicons. Those are stored in ~/.kde/cache-$(hostname)/favicons/. Can you try to pinpoint which file is misinterpreted as a .tga and attach it here or attach a tarball of the favicons/ dir?
Comment 10 LuRan 2009-05-12 04:11:34 UTC
Created attachment 33566 [details]
faviicons

files in the favicons dir
Comment 11 LuRan 2009-05-12 04:13:59 UTC
I have uploaded the files in my favicons dir, but I doubt any of these files is the cause of the crash. I tried to move all the files elsewhere and then I try to type "bugs.kde.org" in the location bar of konqueror, kded freeze and then crashed before the completion widget popup.
Comment 12 Aurelien Gateau 2009-05-12 22:18:26 UTC
You are right. I had a closer look at the crashing code and it actually crashes *before* storing the image in this dir.

It would help if you could do the following:
- Edit kdebase/apps/lib/konq/favicons/favicons.cpp
- Find the "startDownload()" method (line 201 for me)
- Add this line after the opening curly brace:
  kWarning() << iconURL;

This should output the name of the offending url to stderr.
Comment 13 LuRan 2009-05-18 03:28:22 UTC
Ihave tried to add "kWarning() << iconURL;" at the beginning of startDownload(), but I have not get anything useful, kded crashed before I could type in the who url, I typed the first few letters, then the completion widget popup, konqueror freezed, kded crashed. It looks like the completion widget triggered the crash. I guess it is because the little icon in front of those urls in the completion widget. But since the crash still exist after I cleaned up the favicon dir. I do not think the icon comes from some external website. Maybe some icons in oxygen?
Comment 14 Teemu Rytilahti 2009-05-23 23:06:09 UTC
Could this be a dupe of #189338? 

I've encountered the same kind of a crash by khtml where empty url() in a CSS file causes it to try to load "someurl" (perhaps base one..). It seems that the TGAHandler doesn't check the file closely enough and may wrongly interpret it as a TGA file, and then it goes boom when it tries to access the data bits from that file. For a test-case try to load http://www.hs.fi in Konqueror.

So basically (and according to Maks Orlovich) there are three different bugs, direct c&p from an IRC log: "bug #1: it gets detected as TGA, bug #2: the TGA loader gets used when it's not in the whitelist, bug #3: the TGA loader goes boom"
Comment 15 Teemu Rytilahti 2009-05-24 02:12:52 UTC
See http://reviewboard.kde.org/r/756/
Comment 16 Aurelien Gateau 2009-05-26 17:05:25 UTC
(In reply to comment #14)
> So basically (and according to Maks Orlovich) there are three different bugs,
> direct c&p from an IRC log: "bug #1: it gets detected as TGA, bug #2: the TGA
> loader gets used when it's not in the whitelist, bug #3: the TGA loader goes
> boom"

bug #0: KHTML should not try to decode an image if its url is empty :)
Comment 17 Aurelien Gateau 2009-05-26 17:06:26 UTC
(In reply to comment #15)
> See http://reviewboard.kde.org/r/756/

It looks good to me. I marked it as "Ship it".
Comment 18 Teemu Rytilahti 2009-05-26 17:54:24 UTC
SVN commit 973229 by rytilahti:

Be stricter about supported files in TGAHandler to avoid crashes when non-tga file is trying to be processed as a tga one.

BUG:192191


 M  +17 -13    tga.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=973229