Bug 315379

Summary: KDE daemon crashes on wakeup from suspend
Product: [Unmaintained] solid Reporter: rjha <rjha94>
Component: powermanagement-daemonAssignee: Oliver Henshaw <oliver.henshaw>
Status: RESOLVED FIXED    
Severity: crash CC: afiestas, ahepas1999, alboz, arne.henningsen, deviatov, nexces, oliver.henshaw
Priority: NOR    
Version: 4.10.0   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: add debug statements to trace timeout lifetime

Description rjha 2013-02-18 12:32:43 UTC
Application: kded4 ($Id$)
KDE Platform Version: 4.10.00
Qt Version: 4.8.2
Operating System: Linux 3.2.0-37-generic x86_64
Distribution: Linux Mint 13 Maya

-- Information about the crash:
This is a mint 13 maya edition - KDE 4.10 installed using Kubuntu
KDE 4.10 is running inside vmware fusion 4.x on macosx lion

+ I was working in the VM running KDE 4.10 (fullscreen mode)
+ Close the lid of laptop 
+ After some time, open the lid of laptop 
+ KDE daemon has crashed

-- Backtrace:
Application: KDE Daemon (kdeinit4), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fc3b4853780 (LWP 2296))]

Thread 4 (Thread 0x7fc397414700 (LWP 2298)):
#0  0x00007fc3afa5e05d in __pthread_mutex_unlock_usercnt (mutex=<optimized out>, decr=<optimized out>) at pthread_mutex_unlock.c:52
#1  __pthread_mutex_unlock (mutex=0x7fc3900152b0) at pthread_mutex_unlock.c:290
#2  0x00007fc3af1bf5d1 in g_mutex_unlock () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fc3af18398b in g_main_context_query () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007fc3af183faa in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007fc3af18449a in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007fc39de67406 in ?? () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#7  0x00007fc3af1a59e5 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8  0x00007fc3afa5ae9a in start_thread (arg=0x7fc397414700) at pthread_create.c:308
#9  0x00007fc3b207dcbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#10 0x0000000000000000 in ?? ()

Thread 3 (Thread 0x7fc387fff700 (LWP 2301)):
#0  socketNotifierSourceCheck (source=0x7fc380001350) at kernel/qeventdispatcher_glib.cpp:79
#1  0x00007fc3af183b43 in g_main_context_check () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fc3af183fd6 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fc3af184164 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007fc3b34c2906 in QEventDispatcherGlib::processEvents (this=0x7fc3800008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:426
#5  0x00007fc3b3491e42 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#6  0x00007fc3b3492097 in QEventLoop::exec (this=0x7fc387ffee00, flags=...) at kernel/qeventloop.cpp:204
#7  0x00007fc3b3391057 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:501
#8  0x00007fc3b339407b in QThreadPrivate::start (arg=0x23770c0) at thread/qthread_unix.cpp:307
#9  0x00007fc3afa5ae9a in start_thread (arg=0x7fc387fff700) at pthread_create.c:308
#10 0x00007fc3b207dcbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#11 0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7fc3877fe700 (LWP 2308)):
#0  __pthread_mutex_unlock_usercnt (mutex=<optimized out>, decr=<optimized out>) at pthread_mutex_unlock.c:46
#1  __pthread_mutex_unlock (mutex=0x7fc378000a60) at pthread_mutex_unlock.c:290
#2  0x00007fc3af1bf5d1 in g_mutex_unlock () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fc3af1831f8 in g_main_context_acquire () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007fc3af183f04 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007fc3af184164 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007fc3b34c2906 in QEventDispatcherGlib::processEvents (this=0x7fc3780008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:426
#7  0x00007fc3b3491e42 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#8  0x00007fc3b3492097 in QEventLoop::exec (this=0x7fc3877fddd0, flags=...) at kernel/qeventloop.cpp:204
#9  0x00007fc3b3391057 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:501
#10 0x00007fc3b3471b4f in QInotifyFileSystemWatcherEngine::run (this=0x23a6c80) at io/qfilesystemwatcher_inotify.cpp:248
#11 0x00007fc3b339407b in QThreadPrivate::start (arg=0x23a6c80) at thread/qthread_unix.cpp:307
#12 0x00007fc3afa5ae9a in start_thread (arg=0x7fc3877fe700) at pthread_create.c:308
#13 0x00007fc3b207dcbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#14 0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7fc3b4853780 (LWP 2296)):
[KCrash Handler]
#6  QHashData::nextNode (node=0x244f530) at tools/qhash.cpp:294
#7  0x00007fc38d7446ef in operator++ (this=<synthetic pointer>) at /usr/include/qt4/QtCore/qhash.h:427
#8  PowerDevil::Core::onKIdleTimeoutReached (this=0x2347110, identifier=3, msec=60000) at ../../../powerdevil/daemon/powerdevilcore.cpp:674
#9  0x00007fc38d74a3e1 in qt_static_metacall (_a=<optimized out>, _id=<optimized out>, _o=<optimized out>, _c=<optimized out>) at ./powerdevilcore.moc:154
#10 PowerDevil::Core::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at ./powerdevilcore.moc:111
#11 0x00007fc3b34a7761 in QMetaObject::activate (sender=0x244d3f0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff7e672de0) at kernel/qobject.cpp:3547
#12 0x00007fc38d526f4f in KIdleTime::timeoutReached(int, int) () from /usr/lib/libkidletime.so.4
#13 0x00007fc38d52726a in ?? () from /usr/lib/libkidletime.so.4
#14 0x00007fc3b34a7761 in QMetaObject::activate (sender=0x2447790, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff7e672fc0) at kernel/qobject.cpp:3547
#15 0x00007fc38d527a51 in ?? () from /usr/lib/libkidletime.so.4
#16 0x00007fc38d52a743 in ?? () from /usr/lib/libkidletime.so.4
#17 0x00007fc3b4231036 in KApplication::x11EventFilter(_XEvent*) () from /usr/lib/libkdeui.so.5
#18 0x00007fc3b2883aa5 in qt_x11EventFilter (ev=0x7fff7e6735e0) at kernel/qapplication_x11.cpp:441
#19 qt_x11EventFilter (ev=0x7fff7e6735e0) at kernel/qapplication_x11.cpp:429
#20 0x00007fc3b2892eb8 in QApplication::x11ProcessEvent (this=0x7fff7e6739f0, event=0x7fff7e6735e0) at kernel/qapplication_x11.cpp:3444
#21 0x00007fc3b28bd052 in x11EventSourceDispatch (s=0x2076600, callback=0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#22 0x00007fc3af183d53 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#23 0x00007fc3af1840a0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#24 0x00007fc3af184164 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007fc3b34c289f in QEventDispatcherGlib::processEvents (this=0x1fe37d0, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#26 0x00007fc3b28bccde in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#27 0x00007fc3b3491e42 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#28 0x00007fc3b3492097 in QEventLoop::exec (this=0x7fff7e673980, flags=...) at kernel/qeventloop.cpp:204
#29 0x00007fc3b34973e7 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1187
#30 0x00007fc39f903e35 in kdemain () from /usr/lib/kde4/libkdeinit/libkdeinit4_kded4.so
#31 0x000000000040866c in _start ()

Possible duplicates by query: bug 311164, bug 302214.

Reported using DrKonqi
Comment 1 Jekyll Wu 2013-02-18 13:41:51 UTC
*** Bug 302214 has been marked as a duplicate of this bug. ***
Comment 2 Jekyll Wu 2013-02-18 13:41:58 UTC
*** Bug 311164 has been marked as a duplicate of this bug. ***
Comment 3 Alex Fiestas 2013-04-02 19:18:04 UTC
Confirming because of duplicates.
Comment 4 Oliver Henshaw 2013-04-03 18:19:44 UTC
The backtrace in bug #311164 is a little different, it re-enters the event loop several times thanks to KAuth. I'm not sure whether that is safe or not. Anyway, it does eventually crash at the same place so I'm inclined to think it's the same bug.

Are these systems that suspend when the lid is closed or systems that suspend on idle? What version of the x server are you running?

Something might be changing  m_registeredActionTimeouts while we're iterating through it. I'll have a patch to sprinkle in some debug statements at interesting places soon-ish, if there's anyone who reliably hits this crash and can compile their own kde-workspace.
Comment 5 Arne Henningsen 2013-04-04 13:33:07 UTC
The bug occurred when I suspended the system by closing the lid.
Comment 6 Oliver Henshaw 2013-04-04 15:00:34 UTC
Created attachment 78634 [details]
add debug statements to trace timeout lifetime

If anyone can reproduce this at will, please build kde-workspace with this patch and add "kded" (no numbers) in kdebugdialog - do the logout/login dance until the "kded" area shows up.

Then there should be useful information in .xsession-errors next time it crashes.
Comment 7 Oliver Henshaw 2013-04-04 15:05:34 UTC
(In reply to comment #5)
> The bug occurred when I suspended the system by closing the lid.
What version of the x11 server do you have?
Comment 8 Arne Henningsen 2013-04-04 15:23:49 UTC
I had the latest release of Kubuntu (i.e. 12.10) when I reported the bug and I did not change it. Currently, the distribution includes the packages "xserver-xorg 1:7.7+1ubuntu4" and "xserver-xorg-core 2:1.13.0-0ubuntu6.1" (I do not know if they changed the version of the X server during the previous few months). The bug is not reproducible but it occurred a few times.
Comment 9 Oliver Henshaw 2013-04-04 17:38:17 UTC
(In reply to comment #8)
> I had the latest release of Kubuntu (i.e. 12.10) when I reported the bug and
> I did not change it. Currently, the distribution includes the packages
> "xserver-xorg 1:7.7+1ubuntu4" and "xserver-xorg-core 2:1.13.0-0ubuntu6.1"
This sounds like it might be a symptom of bug #310317 - the idle timer should be reset immediately after resume and so idle timeouts should not be happening.

Can you file a bug with ubuntu to update to a recent 1.13.x point release or at least pull in the fix for https://bugs.freedesktop.org/show_bug.cgi?id=56649 ? Ubuntu 13.04 has an up-to-date xserver, fwiw.

Doesn't really explain the crash though. Only that this code is not expected to be called just after resume.
Comment 10 Arne Henningsen 2013-04-05 08:21:05 UTC
OK, I filed this bug with ubuntu:

https://bugs.launchpad.net/ubuntu/+bug/1164876
Comment 11 Jekyll Wu 2013-05-07 14:47:45 UTC
*** Bug 319469 has been marked as a duplicate of this bug. ***
Comment 12 Oliver Henshaw 2013-05-17 13:32:24 UTC
*** Bug 319873 has been marked as a duplicate of this bug. ***
Comment 13 Oliver Henshaw 2013-05-20 11:14:00 UTC
Git commit 9659f99b1b23fbb29612b30ca56553653b9324ec by Oliver Henshaw.
Committed on 04/04/2013 at 17:12.
Pushed by oliverhenshaw into branch 'KDE/4.10'.

Stop searching for timeout once identifier found

The identifier is unique.

Use QList::contains() rather than a nested for loop; break from the
QHash loop once the search succeeds.

Continuing to loop over the action timeouts should be safe but the
brightness action may use KAuth which may return to the event loop; this
allows another event to e.g. call loadProfile() which will reload all
actions and kick over the timeouts.
REVIEW: 110026

M  +6    -8    powerdevil/daemon/powerdevilcore.cpp

http://commits.kde.org/kde-workspace/9659f99b1b23fbb29612b30ca56553653b9324ec
Comment 14 Alex Fiestas 2013-07-28 22:38:48 UTC
The bug is fixed I take.