Bug 253795

Summary: Plasma keeps crashing upon login
Product: [Frameworks and Libraries] kdelibs Reporter: Javier Conti <javier.conti>
Component: kshareddatacacheAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: abenson, alpha_one_x86, andreiamenta, asraniel, biasquez, blazevanderpool, consigliog, eduard.czimbalmos, geraldoav, harry_m, i.semenov.kde, jcnengel, jineshkj.projects, jorma.hytonen, kilem86, mpyne, mvasilchuk, naether.markus, nitro89, sfoerster42, strzol
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: OpenSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: New crash information added by DrKonqi
Add checking of indicated page index to removeEntry
New crash information added by DrKonqi
New crash information added by DrKonqi
New crash information added by DrKonqi

Description Javier Conti 2010-10-10 23:44:26 UTC
Application: plasma-desktop (0.3)
KDE Platform Version: 4.5.2 (KDE 4.5.2)
Qt Version: 4.7.0
Operating System: Linux 2.6.36-rc7-26-desktop x86_64
Distribution: "openSUSE 11.3 (x86_64)"

-- Information about the crash:
Everytime I enter my KDE session, plasma keeps crashing. I have not changed any setting nor installed new widgets since last succesful login. I just performed available software updates.

I also tried to remove my ~/.kde4 but the problem persisted.

The crash can be reproduced every time.

-- Backtrace:
Application: Plasma Workspace (kdeinit4), signal: Segmentation fault
[Current thread is 1 (Thread 0x7f1aae012760 (LWP 3132))]

Thread 2 (Thread 0x7f1a8793d710 (LWP 3209)):
#0  0x00007f1aac995709 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f1aacc1ff12 in wait (this=<value optimized out>, mutex=0x1bdb0b0, time=30000) at thread/qwaitcondition_unix.cpp:86
#2  QWaitCondition::wait (this=<value optimized out>, mutex=0x1bdb0b0, time=30000) at thread/qwaitcondition_unix.cpp:160
#3  0x00007f1aacc15d28 in QThreadPoolThread::run (this=0x1bc8de0) at concurrent/qthreadpool.cpp:140
#4  0x00007f1aacc1f8be in QThreadPrivate::start (arg=0x1bc8de0) at thread/qthread_unix.cpp:266
#5  0x00007f1aac990a4f in start_thread () from /lib64/libpthread.so.0
#6  0x00007f1aab75082d in clone () from /lib64/libc.so.6
#7  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f1aae012760 (LWP 3132)):
[KCrash Handler]
#6  0x00007f1aad17d194 in SharedMemory::removeEntry (this=0x7f1a918a3000, index=9277) at /usr/src/debug/kdelibs-4.5.2/kdecore/util/kshareddatacache.cpp:1160
#7  0x00007f1aad21692f in KSharedDataCache::insert (this=<value optimized out>, key=..., data=...) at /usr/src/debug/kdelibs-4.5.2/kdecore/util/kshareddatacache.cpp:1269
#8  0x00007f1aad9af1bd in KImageCache::insertImage (this=0x7e04d0, key=..., image=...) at /usr/src/debug/kdelibs-4.5.2/kdeui/util/kimagecache.cpp:86
#9  0x00007f1aadabf696 in KImageCache::insertPixmap (this=0x7e04d0, key=..., pixmap=...) at /usr/src/debug/kdelibs-4.5.2/kdeui/util/kimagecache.cpp:105
#10 0x00007f1aa44cdf35 in Plasma::ThemePrivate::scheduledCacheUpdate (this=0x7a85e0) at /usr/src/debug/kdelibs-4.5.2/plasma/theme.cpp:275
#11 0x00007f1aa44d00d2 in Plasma::Theme::qt_metacall (this=0x78ed30, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0x7ffff100bb90) at /usr/src/debug/kdelibs-4.5.2/build/plasma/theme.moc:119
#12 0x00007f1aacd1fb5f in QMetaObject::activate (sender=0x7bad70, m=<value optimized out>, local_signal_index=<value optimized out>, argv=0x0) at kernel/qobject.cpp:3272
#13 0x00007f1aacd1e509 in QObject::event (this=0x7bad70, e=<value optimized out>) at kernel/qobject.cpp:1175
#14 0x00007f1aabeb0f34 in QApplicationPrivate::notify_helper (this=0x683440, receiver=0x7bad70, e=0x7ffff100c330) at kernel/qapplication.cpp:4396
#15 0x00007f1aabeb935a in QApplication::notify (this=<value optimized out>, receiver=0x7bad70, e=0x7ffff100c330) at kernel/qapplication.cpp:4277
#16 0x00007f1aad996826 in KApplication::notify (this=0x673360, receiver=0x7bad70, event=0x7ffff100c330) at /usr/src/debug/kdelibs-4.5.2/kdeui/kernel/kapplication.cpp:310
#17 0x00007f1aacd0a9dc in QCoreApplication::notifyInternal (this=0x673360, receiver=0x7bad70, event=0x7ffff100c330) at kernel/qcoreapplication.cpp:732
#18 0x00007f1aacd38189 in sendEvent (this=0x686ab0) at kernel/qcoreapplication.h:215
#19 QTimerInfoList::activateTimers (this=0x686ab0) at kernel/qeventdispatcher_unix.cpp:617
#20 0x00007f1aacd34f58 in timerSourceDispatch (source=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:184
#21 idleTimerSourceDispatch (source=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:231
#22 0x00007f1aa8855a93 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#23 0x00007f1aa8856270 in ?? () from /usr/lib64/libglib-2.0.so.0
#24 0x00007f1aa8856510 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#25 0x00007f1aacd355ff in QEventDispatcherGlib::processEvents (this=0x673d90, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:415
#26 0x00007f1aabf54eee in QGuiEventDispatcherGlib::processEvents (this=<value optimized out>, flags=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:204
#27 0x00007f1aacd09e12 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#28 0x00007f1aacd0a025 in QEventLoop::exec (this=0x7ffff100c640, flags=...) at kernel/qeventloop.cpp:201
#29 0x00007f1aacd0e43b in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1009
#30 0x00007f1a9d6dfc7b in kdemain (argc=1, argv=0x614e90) at /usr/src/debug/kdebase-workspace-4.5.2/plasma/desktop/shell/main.cpp:118
#31 0x0000000000407509 in _start ()

Reported using DrKonqi
Comment 1 Eduard Czimbalmos 2010-10-11 12:07:19 UTC
Created attachment 52411 [details]
New crash information added by DrKonqi

plasma-desktop (0.3) on KDE Platform 4.5.2 (KDE 4.5.2) using Qt 4.6.3

- What I was doing when the application crashed:

I increased the system date with two hours while the desktop was running.

-- Backtrace (Reduced):
#6  0x00007f562b4796b2 in SharedMemory::removeEntry (this=0x7f56131ad000, index=<value optimized out>) at /var/tmp/portage/kde-base/kdelibs-4.5.2/work/kdelibs-4.5.2/kdecore/util/kshareddatacache.cpp:1160
#7  0x00007f562b47a549 in KSharedDataCache::insert (this=0x7a0550, key=<value optimized out>, data=<value optimized out>) at /var/tmp/portage/kde-base/kdelibs-4.5.2/work/kdelibs-4.5.2/kdecore/util/kshareddatacache.cpp:1269
#8  0x00007f562bccdd3a in KImageCache::insertImage (this=0x7a0550, key=..., image=...) at /var/tmp/portage/kde-base/kdelibs-4.5.2/work/kdelibs-4.5.2/kdeui/util/kimagecache.cpp:86
#9  0x00007f562bcce0c6 in KImageCache::insertPixmap (this=0x7a0550, key=..., pixmap=...) at /var/tmp/portage/kde-base/kdelibs-4.5.2/work/kdelibs-4.5.2/kdeui/util/kimagecache.cpp:105
#10 0x00007f5622a69956 in Plasma::ThemePrivate::scheduledCacheUpdate (this=0x798db0) at /var/tmp/portage/kde-base/kdelibs-4.5.2/work/kdelibs-4.5.2/plasma/theme.cpp:272
Comment 2 Javier Conti 2010-10-11 12:25:32 UTC
The last comment reminded me that I rebooted in Windows, which has the hardware clock in local time, then back to Linux. Probably the clock has been set back to the correct time via NTP when the system was running... so maybe time changes may be the trigger of the problem...
Comment 3 Eduard Czimbalmos 2010-10-11 14:22:16 UTC
Yes, I also have this issue after Windows changes the time.
I was wrong in my comment, instead of increasing the time I _decreased_ the time with two hours.

(In reply to comment #2)
> The last comment reminded me that I rebooted in Windows, which has the hardware
> clock in local time, then back to Linux. Probably the clock has been set back
> to the correct time via NTP when the system was running... so maybe time
> changes may be the trigger of the problem...
Comment 4 Christoph Feck 2010-10-13 19:53:12 UTC
Michael, we get bug reports about crashes when setting the system time back (such as bug 254082). Could it be related to the shared data cache handling of "last use time"?
Comment 5 Beat Wolf 2010-10-14 11:14:04 UTC
*** Bug 254111 has been marked as a duplicate of this bug. ***
Comment 6 Christoph Feck 2010-10-14 16:41:01 UTC
*** Bug 254082 has been marked as a duplicate of this bug. ***
Comment 7 Michael Pyne 2010-10-15 01:29:02 UTC
It's possible, I would imagine that the "free up in-use items" code doesn't typically have to make it all the way to the end of the list of used entries before finding enough room.

I'll take a look into it.
Comment 8 Michael Pyne 2010-10-15 03:59:28 UTC
Created attachment 52526 [details]
Add checking of indicated page index to removeEntry

So, I've tried taking a look:

I /think/ that the crash in removeEntry is an indication of prior corruption, and not the actual root cause. This is because when removeEntry is called by insert at line 1269, the entry that is being removed has been verified in-use by its useCount having been greater than 0. So, firstPage should be valid at this point in execution. Apparently it is not by the time that removeEntry is called.

This patch fixes that *symptom* by checking the return value (or, it should).

I have been testing on trunk, including various combinations of time resets, and forcing the removeEntry call in question to be performed no matter how lightly loaded the cache is and I cannot reproduce. It might be due to the extra care taken when checking whether locks are acquired, which I will investigate. (However I have heard bug reports for this from a Fedora user even on trunk, although that was SIGFPE and not SIGSEGV).
Comment 9 Beat Wolf 2010-10-15 09:46:27 UTC
could you submit this patch to reviewboard.kde.org? here it will just get lost.
thank you
Comment 10 Harry Mueller 2010-10-17 15:35:28 UTC
Created attachment 52614 [details]
New crash information added by DrKonqi

kmix (3.7) on KDE Platform 4.5.2 (KDE 4.5.2) "release 10" using Qt 4.6.3

Why you don't ask for English knowledge in the FIRST Screen of Bugtracker?!

You really beleve, only English speaking People have Problems?

My Problem: last Update from OpenSuSE repo was installed. Now plasma crashed every time.

-- Backtrace (Reduced):
#6  0x00007f45e69e4674 in SharedMemory::removeEntry (this=0x7f45cbd0a000, index=7048) at /usr/src/debug/kdelibs-4.5.2/kdecore/util/kshareddatacache.cpp:1160
#7  0x00007f45e6a7a50f in KSharedDataCache::insert (this=<value optimized out>, key=..., data=...) at /usr/src/debug/kdelibs-4.5.2/kdecore/util/kshareddatacache.cpp:1269
#8  0x00007f45e720c14d in KImageCache::insertImage (this=0x7508c0, key=..., image=...) at /usr/src/debug/kdelibs-4.5.2/kdeui/util/kimagecache.cpp:86
#9  0x00007f45e7320906 in KImageCache::insertPixmap (this=0x7508c0, key=..., pixmap=...) at /usr/src/debug/kdelibs-4.5.2/kdeui/util/kimagecache.cpp:105
#10 0x00007f45ddb94ff5 in Plasma::ThemePrivate::scheduledCacheUpdate (this=0x720930) at /usr/src/debug/kdelibs-4.5.2/plasma/theme.cpp:275
Comment 11 Geraldo Augusto Vecchiato 2010-10-18 19:49:56 UTC
*** Bug 253464 has been marked as a duplicate of this bug. ***
Comment 12 Johannes Engel 2010-10-19 01:12:09 UTC
Created attachment 52666 [details]
New crash information added by DrKonqi

plasma-desktop (0.3) on KDE Platform 4.5.2 (KDE 4.5.2) using Qt 4.7.0

- What I was doing when the application crashed:

Logged on using KDE. I adjusted the timezone in the previous session from London to Berlin after having done the same under Windows before.

-- Backtrace (Reduced):
#6  0x00007f498e069bb4 in SharedMemory::removeEntry (this=0x7f4974037000, index=2449) at /usr/src/debug/kdelibs-4.5.2/kdecore/util/kshareddatacache.cpp:1160
#7  0x00007f498e0ff92f in KSharedDataCache::insert (this=<value optimized out>, key=..., data=...) at /usr/src/debug/kdelibs-4.5.2/kdecore/util/kshareddatacache.cpp:1269
#8  0x00007f498e8981dd in KImageCache::insertImage (this=0x771f50, key=..., image=...) at /usr/src/debug/kdelibs-4.5.2/kdeui/util/kimagecache.cpp:86
#9  0x00007f498e9a8236 in KImageCache::insertPixmap (this=0x771f50, key=..., pixmap=...) at /usr/src/debug/kdelibs-4.5.2/kdeui/util/kimagecache.cpp:105
#10 0x00007f49853b1f35 in Plasma::ThemePrivate::scheduledCacheUpdate (this=0x76c740) at /usr/src/debug/kdelibs-4.5.2/plasma/theme.cpp:275
Comment 13 Christoph Feck 2010-10-19 16:22:45 UTC
*** Bug 254625 has been marked as a duplicate of this bug. ***
Comment 14 Beat Wolf 2010-10-19 16:27:25 UTC
*** Bug 254176 has been marked as a duplicate of this bug. ***
Comment 15 Geraldo Augusto Vecchiato 2010-10-20 23:26:59 UTC
This patch solved the problem for me. Thanks.

When it will be in SVN?

(In reply to comment #8)
> Created an attachment (id=52526) [details]
> Add checking of indicated page index to removeEntry
> 
> So, I've tried taking a look:
> 
> I /think/ that the crash in removeEntry is an indication of prior corruption,
> and not the actual root cause. This is because when removeEntry is called by
> insert at line 1269, the entry that is being removed has been verified in-use
> by its useCount having been greater than 0. So, firstPage should be valid at
> this point in execution. Apparently it is not by the time that removeEntry is
> called.
> 
> This patch fixes that *symptom* by checking the return value (or, it should).
> 
> I have been testing on trunk, including various combinations of time resets,
> and forcing the removeEntry call in question to be performed no matter how
> lightly loaded the cache is and I cannot reproduce. It might be due to the
> extra care taken when checking whether locks are acquired, which I will
> investigate. (However I have heard bug reports for this from a Fedora user even
> on trunk, although that was SIGFPE and not SIGSEGV).
Comment 16 Beat Wolf 2010-10-20 23:34:03 UTC
i don't think the patch was ever submitted. i hope this will be done, or else it will get lost.
Comment 17 Michael Pyne 2010-10-21 02:11:23 UTC
SVN commit 1187997 by mpyne:

Add a "valid page" check to KSharedDataCache, which seems to prevent crashing when changing
the system time.

Adding the check is a good idea anyways, but only solves the symptom of some underlying
logic error that I can't reproduce (or understand how it occurs either :P). This applies to
trunk (Platform 4.6), I will backport to 4.5.3.

CCBUG:253795


 M  +8 -2      kshareddatacache.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1187997
Comment 18 Michael Pyne 2010-10-21 02:16:27 UTC
SVN commit 1187999 by mpyne:

Backport a "valid page" check for KSharedDataCache to KDE 4.5.3.

This adds additional checks that seem to prevent crashes when changing the system time.
This only masks the symptom though, it should be a logic error to be removing a page
that is already marked as free in the code paths that could reach the affected function.
Either way, it's one less crash.

I'll leave the bug open until I feel I've figured out why the underlying cause of the
bug when changing system time.

As an aside to Beat Wolf, I am just as likely (if not more) to lose patches on
ReviewBoard as I am on bugs.kde.org.  Adding BugZilla attachments to
ReviewBoard isn't necessary for that reason, ReviewBoard should be for things
that require actual code review. ;)

CCBUG:253795


 M  +8 -2      kshareddatacache.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1187999
Comment 19 Beat Wolf 2010-10-21 09:45:25 UTC
Sorry, i forgot to read your name so i didn't see that you are a actual developer, i thought you where a regular user, and in that case reviewboard is really handy.

Thanks for fixing anyway :)
Comment 20 Christoph Feck 2010-10-30 13:54:37 UTC
*** Bug 255551 has been marked as a duplicate of this bug. ***
Comment 21 Christoph Feck 2010-10-30 13:57:12 UTC
From bug 255551:

"I do not think this is the same bug [...] because this
problem happens if and only if I [reboot after using] dual displays."
Comment 22 Stefan Foerster 2010-10-31 08:43:28 UTC
The same here. The plasma desktop crashes in loops when starting KDE 4.5.2 on my Gentoo machine.

In Germany (and other European countries) the daylight savings time has been changed back to winter time today at 03:00. When I started my computer this morning, the time on my machine had not been changed. ntp-client was not running and was not configured correctly. Thus I changed my ntp-client settings, started "ntp-client" and restarted "ntpd" while KDE was running. The clock changed back 1 hour. A few seconds later I had the first segmentation fault.

I restarted KDE and I even rebooted, but KDE keeps crashing in a loop.

Probably a huge number of people had been affected - the patch is urgently needed.
Comment 23 Nitro Nexus 2010-10-31 09:35:54 UTC
Created attachment 53010 [details]
New crash information added by DrKonqi

krunner (0.1) on KDE Platform 4.5.2 (KDE 4.5.2) using Qt 4.7.0

I've the same problem. All kde application (krunner, kwin, plasma etc...) crashes at login.

-- Backtrace (Reduced):
#6  0x00007f8d534933e2 in SharedMemory::removeEntry (this=0x7f8d38f7b000, index=<value optimized out>) at ../../kdecore/util/kshareddatacache.cpp:1160
#7  0x00007f8d534945e3 in KSharedDataCache::insert (this=0x1e99a80, key=<value optimized out>, data=<value optimized out>) at ../../kdecore/util/kshareddatacache.cpp:1269
#8  0x00007f8d5547ef4d in KImageCache::insertImage (this=0x1e99a80, key=..., image=...) at ../../kdeui/util/kimagecache.cpp:86
#9  0x00007f8d5547f336 in KImageCache::insertPixmap (this=0x1e99a80, key=..., pixmap=...) at ../../kdeui/util/kimagecache.cpp:105
#10 0x00007f8d559c5292 in Plasma::ThemePrivate::scheduledCacheUpdate (this=0x1e753c0) at ../../plasma/theme.cpp:272
Comment 24 Christoph Feck 2010-10-31 15:01:44 UTC
*** Bug 255717 has been marked as a duplicate of this bug. ***
Comment 25 Christoph Feck 2010-10-31 15:27:00 UTC
*** Bug 255743 has been marked as a duplicate of this bug. ***
Comment 26 Christoph Feck 2010-10-31 15:27:36 UTC
*** Bug 255709 has been marked as a duplicate of this bug. ***
Comment 27 Christoph Feck 2010-10-31 15:28:04 UTC
*** Bug 255719 has been marked as a duplicate of this bug. ***
Comment 28 Christoph Feck 2010-10-31 15:34:27 UTC
*** Bug 253469 has been marked as a duplicate of this bug. ***
Comment 29 Pino Toscano 2010-11-04 21:00:42 UTC
*** Bug 256072 has been marked as a duplicate of this bug. ***
Comment 30 Pino Toscano 2010-12-03 23:43:41 UTC
*** Bug 258740 has been marked as a duplicate of this bug. ***
Comment 31 Michael Pyne 2010-12-27 01:00:52 UTC
*** Bug 261278 has been marked as a duplicate of this bug. ***
Comment 32 Michael Pyne 2011-01-17 01:01:52 UTC
SVN commit 1214946 by mpyne:

Backport "Fully clear cache metadata in clearInternal()" to 4.6.

KSharedDataCache uses the clearInternal() method to reset the cache, which is
used if corruption is detected, and when directed through
KSharedDataCache::clear().  For whatever reason I thought that simply setting
the "first page" pointer for each possible index entry would be sufficient, but
that is not the case at all, as various methods which go through the cache
entries also check things such as the use count, last access time, etc.

Assuming no other errors (:-/) this should be the cause of bug 260309. (The
exact sequence would be a KSharedDataCache user runs ::clear(), later adds some
entries that invoke removeUsedPages(), and removeUsedPages() goes through *all*
index entries, including ones that appear to be in use since their use count is
>0, but their first page is still invalid). Easiest way to invoke this bug I've
found is to simply run "plasmoidviewer clock" at a konsole.

This should fix the annoying bug 260309 just in time for KDE Platform 4.6. I'm
CC-ing release team so that there are no surprises, but I have hopefully
demonstrated enough of the issue to prove that this patch is at least "more
correct" than previous behavior.

It is possible that this was also the proximate cause of the Plasma crashes
when changing the system time for Daylight Savings (which I worked around with
the error message you've been seeing for months), bug 253795.

FIXED-IN:4.6
BUG:260309
CCBUG:253795
CCMAIL:release-team@kde.org


 M  +5 -0      kshareddatacache.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1214946
Comment 33 Jekyll Wu 2011-12-10 04:39:17 UTC
*** Bug 270917 has been marked as a duplicate of this bug. ***
Comment 34 Michael Pyne 2012-05-19 22:18:44 UTC
Seems like there's no further issues with this particular bug given how quiet it has been -> closing.