Summary: | Amarok startup hangs for 5 seconds in KSystemTimeZonesPrivate::instance() - race condition with Telepathy Integration kded4 Module | ||
---|---|---|---|
Product: | [Unmaintained] telepathy | Reporter: | Matěj Laitl <matej> |
Component: | kded-module | Assignee: | Telepathy Bugs <kde-telepathy-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | alex.merry, amarok-bugs-dist, cfeck, ddomenichelli, kde-telepathy-bugs, kde, mklapetek |
Priority: | NOR | ||
Version: | 0.5.1 | ||
Target Milestone: | 0.5-next | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/telepathy-kded-module/b03f8da1eb88d2fbeac5f936cf74a7f72612011d | Version Fixed In: | 0.5.2 |
Sentry Crash Report: |
Description
Matěj Laitl
2012-11-28 15:11:59 UTC
As far as I know, it tries to contact kded4. If that process blocks due to a broken module, you will get the delay. To can confirm this is the case, please try disabling kded4 modules in turn, to find the offending module. For more information, see http://kdepepo.wordpress.com/2011/05/11/troubleshooting-kded4-bugs/ (In reply to comment #1) > As far as I know, it tries to contact kded4. If that process blocks due to a > broken module, you will get the delay. To can confirm this is the case, > please try disabling kded4 modules in turn, to find the offending module. Okay, let's see. I've attached gdb to kded4 while Amarok was hanging. The hang prolonged to something that feels like 25-second timeout of the DBUS call, so it seems that kded4 is the culprit. The kded4 backtrace was always the same 3 times I've tried starting again: Thread 3 (Thread 0x7f54e66be700 (LWP 1615)): #0 0x00007f54ff6cf233 in select () at ../sysdeps/unix/syscall-template.S:82 #1 0x00007f5500deaa8c in QProcessManager::run (this=0x7f5501179440) at io/qprocess_unix.cpp:245 #2 0x00007f5500cfd048 in QThreadPrivate::start (arg=0x7f5501179440) at thread/qthread_unix.cpp:338 #3 0x00007f5500a65da6 in start_thread (arg=0x7f54e66be700) at pthread_create.c:305 #4 0x00007f54ff6d5abd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115 Thread 2 (Thread 0x7f54e49ed700 (LWP 1661)): #0 0x00007f54ff6ccbc3 in *__GI___poll (fds=<optimized out>, nfds=<optimized out>, timeout=<optimized out>) at ../sysdeps/unix/sysv/linux/poll.c:87 #1 0x00007f54fc3aa936 in g_main_context_poll (n_fds=2, fds=0x7f54d80029b0, timeout=-1, context=0x7f54d80009a0, priority=<optimized out>) at gmain.c:3440 #2 g_main_context_iterate (context=0x7f54d80009a0, block=1, dispatch=1, self=<optimized out>) at gmain.c:3141 #3 0x00007f54fc3aaa54 in g_main_context_iteration (context=0x7f54d80009a0, may_block=1) at gmain.c:3207 #4 0x00007f5500e43276 in QEventDispatcherGlib::processEvents (this=0x7f54d80008c0, flags=<optimized out>) at kernel/qeventdispatcher_glib.cpp:426 #5 0x00007f5500e0f4d2 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149 #6 0x00007f5500e0f765 in QEventLoop::exec (this=0x7f54e49ecda0, flags=...) at kernel/qeventloop.cpp:204 #7 0x00007f5500cfaa98 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:501 #8 0x00007f5500dec820 in QInotifyFileSystemWatcherEngine::run (this=0x1d12660) at io/qfilesystemwatcher_inotify.cpp:248 #9 0x00007f5500cfd048 in QThreadPrivate::start (arg=0x1d12660) at thread/qthread_unix.cpp:338 #10 0x00007f5500a65da6 in start_thread (arg=0x7f54e49ed700) at pthread_create.c:305 #11 0x00007f54ff6d5abd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115 Thread 1 (Thread 0x7f54f92fd780 (LWP 1610)): #0 0x00007f54ff6ccbc3 in *__GI___poll (fds=<optimized out>, nfds=<optimized out>, timeout=<optimized out>) at ../sysdeps/unix/sysv/linux/poll.c:87 #1 0x00007f54fa58b080 in socket_do_iteration (transport=0x1b23f70, flags=6, timeout_milliseconds=<optimized out>) at /var/tmp/portage/sys-apps/dbus-1.6.8/work/dbus-1.6.8/dbus/dbus-transport-socket.c:1125 #2 0x00007f54fa589f6d in _dbus_transport_do_iteration (transport=0x1b23f70, flags=<optimized out>, timeout_milliseconds=<optimized out>) at /var/tmp/portage/sys-apps/dbus-1.6.8/work/dbus-1.6.8/dbus/dbus-transport.c:976 #3 0x00007f54fa5783a5 in _dbus_connection_do_iteration_unlocked (connection=0x1b24660, pending=<optimized out>, flags=6, timeout_milliseconds=24362) at /var/tmp/portage/sys-apps/dbus-1.6.8/work/dbus-1.6.8/dbus/dbus-connection.c:1234 #4 0x00007f54fa5793a9 in _dbus_connection_block_pending_call (pending=0x2573840) at /var/tmp/portage/sys-apps/dbus-1.6.8/work/dbus-1.6.8/dbus/dbus-connection.c:2510 #5 0x00007f54fa5789ed in dbus_connection_send_with_reply_and_block (connection=0x1b24660, message=0x270caa0, timeout_milliseconds=-1, error=0x7fff492d6790) at /var/tmp/portage/sys-apps/dbus-1.6.8/work/dbus-1.6.8/dbus/dbus-connection.c:3530 #6 0x00007f54fda34327 in q_dbus_connection_send_with_reply_and_block (error=0x7fff492d6790, timeout_milliseconds=-1, message=0x270caa0, connection=<optimized out>) at qdbus_symbols_p.h:135 #7 QDBusConnectionPrivate::sendWithReply (this=0x1b20570, message=..., sendMode=<optimized out>, timeout=-1) at qdbusintegrator.cpp:1904 #8 0x00007f54fda34d7c in QDBusConnectionPrivate::findMetaObject (this=0x1b20570, service=..., path=<optimized out>, interface=..., error=...) at qdbusintegrator.cpp:2356 #9 0x00007f54fda44173 in QDBusInterfacePrivate::QDBusInterfacePrivate (this=0x2457cd0, serv=<optimized out>, p=<optimized out>, iface=<optimized out>, con=<optimized out>) at qdbusinterface.cpp:158 #10 0x00007f54fda442b9 in QDBusInterface::QDBusInterface (this=0x7fff492d6d90, service=..., path=..., interface=..., connection=<optimized out>, parent=0x0) at qdbusinterface.cpp:220 #11 0x00007f54deefc4c3 in TelepathyMPRIS::detectPlayers (this=0x2079f90) at /var/tmp/portage/net-im/ktp-kded-module-0.5.1/work/ktp-kded-integration-module-0.5.1/telepathy-mpris.cpp:104 #12 0x00007f54deefcc67 in TelepathyMPRIS::serviceOwnerChanged (this=0x2079f90, serviceName=<optimized out>, oldOwner=<optimized out>, newOwner=<optimized out>) at /var/tmp/portage/net-im/ktp-kded-module-0.5.1/work/ktp-kded-integration-module-0.5.1/telepathy-mpris.cpp:163 #13 0x00007f5500e298a0 in QMetaObject::activate (sender=0x1b242f0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff492d70d0) at kernel/qobject.cpp:3547 #14 0x00007f54fda70b3f in QDBusConnectionInterface::serviceOwnerChanged (this=<optimized out>, _t1=<optimized out>, _t2=<optimized out>, _t3=<optimized out>) at .moc/debug-shared/moc_qdbusconnectioninterface.cpp:224 #15 0x00007f54fda71117 in QDBusConnectionInterface::qt_static_metacall (_o=0x1b242f0, _c=<optimized out>, _id=2, _a=0x7fff492d73b0) at .moc/debug-shared/moc_qdbusconnectioninterface.cpp:114 #16 0x00007f5500e298a0 in QMetaObject::activate (sender=0x1b242f0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff492d73b0) at kernel/qobject.cpp:3547 #17 0x00007f54fda70c0f in QDBusConnectionInterface::NameOwnerChanged (this=<optimized out>, _t1=<optimized out>, _t2=<optimized out>, _t3=<optimized out>) at .moc/debug-shared/moc_qdbusconnectioninterface.cpp:252 #18 0x00007f54fda70f9f in QDBusConnectionInterface::qt_static_metacall (_o=0x1b242f0, _c=<optimized out>, _id=6, _a=0x7fff492d75e0) at .moc/debug-shared/moc_qdbusconnectioninterface.cpp:118 #19 0x00007f54fda7148f in QDBusConnectionInterface::qt_metacall (this=0x1b242f0, _c=QMetaObject::InvokeMetaMethod, _id=6, _a=0x7fff492d75e0) at .moc/debug-shared/moc_qdbusconnectioninterface.cpp:177 #20 0x00007f54fda2fe8a in QDBusConnectionPrivate::deliverCall (this=0x1b20570, object=0x1b242f0, msg=..., metaTypes=<optimized out>, slotIdx=11) at qdbusintegrator.cpp:947 #21 0x00007f5500e27aa6 in QObject::event (this=0x1b242f0, e=<optimized out>) at kernel/qobject.cpp:1195 #22 0x00007f54ffe79634 in QApplicationPrivate::notify_helper (this=0x1b30b50, receiver=0x1b242f0, e=0x24b93d0) at kernel/qapplication.cpp:4557 #23 0x00007f54ffe7ea03 in QApplication::notify (this=<optimized out>, receiver=0x1b242f0, e=0x24b93d0) at kernel/qapplication.cpp:4418 #24 0x00007f5501c09da6 in KApplication::notify (this=0x7fff492d82b0, receiver=0x1b242f0, event=0x24b93d0) at /var/tmp/portage/kde-base/kdelibs-4.9.3/work/kdelibs-4.9.3/kdeui/kernel/kapplication.cpp:311 #25 0x00007f5500e1103c in QCoreApplication::notifyInternal (this=0x7fff492d82b0, receiver=0x1b242f0, event=0x24b93d0) at kernel/qcoreapplication.cpp:915 #26 0x00007f5500e146ec in sendEvent (event=0x24b93d0, receiver=0x1b242f0) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231 #27 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x1a942b0) at kernel/qcoreapplication.cpp:1539 #28 0x00007f5500e43083 in sendPostedEvents () at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236 #29 postEventSourceDispatch (s=<optimized out>) at kernel/qeventdispatcher_glib.cpp:279 #30 0x00007f54fc3aa653 in g_main_dispatch (context=0x1b32000) at gmain.c:2539 #31 g_main_context_dispatch (context=0x1b32000) at gmain.c:3075 #32 0x00007f54fc3aa998 in g_main_context_iterate (context=0x1b32000, block=1, dispatch=1, self=<optimized out>) at gmain.c:3146 #33 0x00007f54fc3aaa54 in g_main_context_iteration (context=0x1b32000, may_block=1) at gmain.c:3207 #34 0x00007f5500e4321f in QEventDispatcherGlib::processEvents (this=0x1a967d0, flags=<optimized out>) at kernel/qeventdispatcher_glib.cpp:424 #35 0x00007f54fff2b99e in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=<optimized out>) at kernel/qguieventdispatcher_glib.cpp:204 #36 0x00007f5500e0f4d2 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149 #37 0x00007f5500e0f765 in QEventLoop::exec (this=0x7fff492d8200, flags=...) at kernel/qeventloop.cpp:204 #38 0x00007f5500e14b4b in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1187 #39 0x00007f54ec8e5e17 in kdemain (argc=1, argv=0x1b0e490) at /var/tmp/portage/kde-base/kdelibs-4.9.3/work/kdelibs-4.9.3/kded/kded.cpp:924 #40 0x000000000040754c in launch (argc=1, _name=0x40b78b "kded4", args=<optimized out>, cwd=0x0, envc=<optimized out>, envs=<optimized out>, reset_env=false, tty=0x0, avoid_loops=false, startup_id_str=0x40b626 "0") at /var/tmp/portage/kde-base/kdelibs-4.9.3/work/kdelibs-4.9.3/kinit/kinit.cpp:726 #41 0x0000000000409de6 in main (argc=2, argv=0x7fff492d90a8, envp=0x7fff492d90c0) at /var/tmp/portage/kde-base/kdelibs-4.9.3/work/kdelibs-4.9.3/kinit/kinit.cpp:1841 Wild guess: the TelepathyMPRIS::detectPlayers looks suspicious. MPRIS is a DBUS standard for media players that Amarok implements and advertises over dbus. A race condition comes to my mind: 1. Amarok is started, advertises MPIRS interface over DBUS 2. Amarok calls KCalendarSystem::formatDate() somewhen in the start-up sequence, which launches blocking DBUS call to kded4 2. At the nearly same time, kded4 triggers TelepathyMPRIS::detectPlayers(), which launches blocking DBUS call to amarok 3. -> soft dead-lock. The question is why that exact timing happens so often. Telepathy Integration Module is a load-on-demand kded4 service, and I cannot trigger it to unload despite turning off KDE telepathy and removing all telepathy-related plasmoids. Will try logging out. Okay, it's definitely caused by Telepathy Integration kded4 Module, when I start a new session without it running, I'm unable to reproduce the bug. When I add KTP Presence applet to Plasma Desktop, which triggers Telepathy Integration kded4 Modul load, the bug appears on next Amarok startup. One may wonder what Telepathy could do with MPRIS. I've used "Now Listening to" idle message functionality in KDE Telepathy in past, so that may be the use. The question is now how to solve this. A simple work-around could be to pospone publishing the MPRIS interface in Amarok a few seconds, but this seems hacky. A "proper" solution IMO would be if both KSystemTimeZonesPrivate::instance() and TelepathyMPRIS::detectPlayers() used *async* DBUS methods, if possible. Should this bug be reassigned to KDE Telepathy? The KSystemTimeZonesPrivate::instance() situation looks suboptimal to me. TelepathyMPRIS::detectPlayers() does use async DBus methods (from 0.4 onwards), so I don't think we (KTp) are doing anything wrong? (In reply to comment #4) > TelepathyMPRIS::detectPlayers() does use async DBus methods (from 0.4 > onwards), so I don't think we (KTp) are doing anything wrong? Hmm, I have ktp-kded-module-0.5.1. From the backtrace #7 QDBusConnectionPrivate::sendWithReply (this=0x1b20570, message=..., sendMode=<optimized out>, timeout=-1) at qdbusintegrator.cpp:1904 #8 0x00007f54fda34d7c in QDBusConnectionPrivate::findMetaObject (this=0x1b20570, service=..., path=<optimized out>, interface=..., error=...) at qdbusintegrator.cpp:2356 #9 0x00007f54fda44173 in QDBusInterfacePrivate::QDBusInterfacePrivate (this=0x2457cd0, serv=<optimized out>, p=<optimized out>, iface=<optimized out>, con=<optimized out>) at qdbusinterface.cpp:158 #10 0x00007f54fda442b9 in QDBusInterface::QDBusInterface (this=0x7fff492d6d90, service=..., path=..., interface=..., connection=<optimized out>, parent=0x0) at qdbusinterface.cpp:220 #11 0x00007f54deefc4c3 in TelepathyMPRIS::detectPlayers (this=0x2079f90) at /var/tmp/portage/net-im/ktp-kded-module-0.5.1/work/ktp-kded-integration-module-0.5.1/telepathy-mpris.cpp:104 it seem that merely creating a QDBusInterface is synchronous. :-( But I think my original wild guess doesn't seem to be right. Does the line QDBusInterface mprisInterface(service, QLatin1String("/org/mpris/MediaPlayer2"), QLatin1String("org.freedesktop.DBus.Properties")); try to contact Amarok in any way? I bet it's QDBusConnectionInterface::registeredServiceNames that's synchronous. Though there's no async equivalent that I'm aware of. That would probably match the line in your code you're showing me. We call that on load to find the players so we can start our async calls to it to find out if it's playing anything. Looking at this code, it could be optimised, but we still need to call this method on load, and your potential lock still exists. (In reply to comment #6) > I bet it's QDBusConnectionInterface::registeredServiceNames that's > synchronous. Though there's no async equivalent that I'm aware of. > That would probably match the line in your code you're showing me. Hmm, it doesn't show up in the backtrace. QDBusConnectionPrivate::findMetaObject() really calls QDBusMessage reply = sendWithReply(msg, QDBus::Block); in qdbuintegrator.cpp:2356. Subscribing Alex Merry as he is a MPRIS specialist. The way I dealt with registeredBusNames being synchronous in the Plasma mpris2 dataengine was to manually construct a call to it: QDBusPendingCall async = QDBusConnection::sessionBus().interface()->asyncCall("ListNames"); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this); connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(serviceNameFetchFinished(QDBusPendingCallWatcher*))); Incidentally, it sounds like TelepathyMPRIS is calling registeredServiceNames multiple times in one session, which shouldn't really be happening. You need to call it once to get a list of the players that are *already running*, but after that you should just be using QDBusServiceWatcher to keep track of which MPRIS-capable players are around. Thanks a lot, I'll try to fix it on the ktp side then. Reassigning to KDE Telepathy For future: I'd rather you made a new bug rather than reassigning, then mark the original as blocked. By reassigning, someone searching for Amarok slow startup time will not be able to find this. Also our bug is that we make a synchronous dbus call, we can fix and close that, but it's not our place to say that the bug in Amarok is fixed. Git commit b03f8da1eb88d2fbeac5f936cf74a7f72612011d by Martin Klapetek. Committed on 12/12/2012 at 02:05. Pushed by mklapetek into branch 'kde-telepathy-0.5'. Look async'sly for mpris2 dbus interfaces QDBusConnection::sessionBus().interface()->registeredServiceNames() is sync dbus call, freezing some things while being called. This does that call in async way. REVIEW: 107605 M +21 -2 telepathy-mpris.cpp M +3 -0 telepathy-mpris.h http://commits.kde.org/telepathy-kded-module/b03f8da1eb88d2fbeac5f936cf74a7f72612011d (In reply to comment #14) > Git commit b03f8da1eb88d2fbeac5f936cf74a7f72612011d by Martin Klapetek. > > Look async'sly for mpris2 dbus interfaces Thanks! Will test when you release 0.5.2 and Gentoo packages it and report back in unlikely occasion that I'm still able to reproduce. |