Bug 299714 - KSharedDataCache/KIcon triggers a bus error
Summary: KSharedDataCache/KIcon triggers a bus error
Status: RESOLVED NOT A BUG
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kshareddatacache (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR major
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-10 00:59 UTC by Aleix Pol
Modified: 2014-12-30 00:38 UTC (History)
2 users (show)

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


Attachments
More error-handling for KSharedDataCache (36.46 KB, patch)
2012-05-18 04:11 UTC, Michael Pyne
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aleix Pol 2012-05-10 00:59:48 UTC
In one of the unit tests in KDevelop I a "Bus Error" (SIGBUS). If I run it on valgrind, I get the following backtrace. Looks like a bug in KSharedDataCache...

==1917== Warning: set address range perms: large range [0x39446000, 0x86877000) (defined)
==1917== 
==1917== Process terminating with default action of signal 7 (SIGBUS)
==1917==  Non-existent physical address at address 0x39446048
==1917==    at 0x9D7594B: KSharedDataCache::Private::lock() const (kshareddatacache.cpp:1131)
==1917==    by 0x9D75B0F: KSharedDataCache::Private::CacheLocker::cautiousLock() (kshareddatacache.cpp:1154)
==1917==    by 0x9D75E8B: KSharedDataCache::Private::CacheLocker::CacheLocker(KSharedDataCache::Private const*) (kshareddatacache.cpp:1229)
==1917==    by 0x9D72BA8: KSharedDataCache::find(QString const&, QByteArray*) const (kshareddatacache.cpp:1508)
==1917==    by 0x86A6534: KIconLoaderPrivate::findCachedPixmapWithPath(QString const&, QPixmap&, QString&) (kiconloader.cpp:860)
==1917==    by 0x86A7CF2: KIconLoader::loadIcon(QString const&, KIconLoader::Group, int, int, QStringList const&, QString*, bool) const (kiconloader.cpp:1222)
==1917==    by 0x86A270C: KIconEngine::pixmap(QSize const&, QIcon::Mode, QIcon::State) (kiconengine.cpp:104)
==1917==    by 0x8E6BEC4: QIcon::pixmap(QSize const&, QIcon::Mode, QIcon::State) const (in /usr/lib/libQtGui.so.4.8.1)
==1917==    by 0x60AE372: Sublime::AreaTabButton::AreaTabButton(QString, QIcon, unsigned int, QWidget*, bool, QWidget*) (mainwindow_p.cpp:831)
==1917==    by 0x60A7044: Sublime::AreaTabBar::addCustomTab(QString, QIcon, bool, QString, QWidget*) (mainwindow_p.h:97)
==1917==    by 0x60A429F: Sublime::MainWindow::setupAreaSelector() (mainwindow.cpp:104)
==1917==    by 0x63498A8: KDevelop::MainWindow::loadSettings() (mainwindow.cpp:208)

Reproducible: Always

Steps to Reproduce:
1. compile kdevelop
2. run <builddir>/languages/cpp/tests/buddiestest
3. boom
Comment 1 Michael Pyne 2012-05-11 00:23:05 UTC
The testsuite passes here without issue. :-/

KSharedDataCache does probably need better error-checking though, no excuse for a corrupted cache to induce SIGBUS.
Comment 2 Aleix Pol 2012-05-11 00:40:15 UTC
Yes, I've discussed with Milian (also from kdevelop) and he can't reproduce it either.

Do you have any idea of how can I figure out what's going on?
Comment 3 Michael Pyne 2012-05-11 00:47:41 UTC
Specifically what's going on, probably not. It's undoubtedly a corrupted cache file somehow so a quick fix would be to delete the icon cache (normally /var/tmp/kdecache-$USER/icon-cache.kcache).

There's a debug area for KSharedDataCache and KIconLoader which you can enable as well, might tell you which icon ended up corrupted.
Comment 4 Aleix Pol 2012-05-11 01:05:03 UTC
I don't have this directory for this user (the kde-devel user), the other one does, though. Could that be a problem?

I added those debug areas and they're not adding any output :/
Comment 5 Michael Pyne 2012-05-11 01:13:23 UTC
Well, it's possible that the missing directory is the issue, but then KSharedDataCache should fail much earlier in the process... the exact setting for the directory is returned by "kde4-config --path cache", which should return /something/ even for your kde-devel user, I would hope!
Comment 6 Aleix Pol 2012-05-11 01:58:54 UTC
kde-devel@thinktatil:~/build-kdevelop/languages/cpp$ kde4-config --path cache
/home/kde-devel/.kde4/cache-thinktatil/

So I removed the icon cache, I keep having this problem, the SIGBUS... :/
Comment 7 Michael Pyne 2012-05-18 04:11:16 UTC
Created attachment 71175 [details]
More error-handling for KSharedDataCache

Aleix, if you're still experiencing the crash then please test this patch. It adds more error checking against invalid data page access, valid cache page sizes, etc. I've tried replacing some caches with random data here without leading to crashes so hopefully it makes it a bit more resilient for you at least.
Comment 8 Aleix Pol 2014-12-30 00:38:34 UTC
Haven't had it for a while, and not really using that codebase anymore. Closing.