After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 707274 - manager: fix deadlock when registering XSMP clients at login
manager: fix deadlock when registering XSMP clients at login
Status: RESOLVED FIXED
Product: gnome-session
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Session Maintainers
Session Maintainers
Depends on: 707302
Blocks:
 
 
Reported: 2013-09-02 09:28 UTC by Cosimo Cecchi
Modified: 2013-09-16 20:45 UTC
See Also:
GNOME target: 3.10
GNOME version: ---


Attachments
manager: fix deadlock when registering XSMP clients at login (4.96 KB, patch)
2013-09-02 09:28 UTC, Cosimo Cecchi
committed Details | Review
GsmPresence: don't check the idletime after adding an idle watch (1.57 KB, patch)
2013-09-02 18:57 UTC, Giovanni Campagna
committed Details | Review

Description Cosimo Cecchi 2013-09-02 09:28:21 UTC
See attached patch.
This fixes the delayed login bug that can be seen using git master versions of mutter and gnome-desktop.
Comment 1 Cosimo Cecchi 2013-09-02 09:28:22 UTC
Created attachment 253815 [details] [review]
manager: fix deadlock when registering XSMP clients at login

gnome-session will switch to the next phase whenever the list of
applications pending registration is emptied.
Previously, for XSMP clients, the code in GsmXSMPClient would signal
that an application was registered before sending the reply through
SmsRegisterClientReply().
As GnomeIdleMonitor will now call into Mutter through DBus, and the
RUNNING phase of the session will initialize its presence component that
uses the monitor, we will end up in a situation where Mutter is waiting
for the XSMP reply from gnome-session, and gnome-session is waiting for
a synchronous DBus reply from Mutter, effectively locking up the login
process until the DBus timeout occurs.

This commit fixes the bug by signalling XSMP app registration only after
the reply has been sent over the wire.
Comment 2 Colin Walters 2013-09-02 16:53:37 UTC
Review of attachment 253815 [details] [review]:

First: *thank you* for finding this bug!  It's been annoying me a while in gnome-ostree.  Great commit message diagnosis.  

The fix looks plausible, but the regression happened when gnome-desktop's GnomeIdleMonitor was changed to synchronously call into mutter, and I think we should also fix it there.

(Man, the relationship between gnome-session, gnome-settings-daemon, and gnome-shell is such a tangled mess...)

I'd like to see either Giovanni or Ray sign off on this patch too.
Comment 3 Giovanni Campagna 2013-09-02 17:06:29 UTC
But the IdleMonitor DBus API is completely async, how is it possible to deadlock?
Comment 4 Colin Walters 2013-09-02 17:43:30 UTC
(In reply to comment #3)
> But the IdleMonitor DBus API is completely async, how is it possible to
> deadlock?

At least gnome_idle_monitor_get_idletime is a synchronous call.
Comment 5 Giovanni Campagna 2013-09-02 18:01:57 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > But the IdleMonitor DBus API is completely async, how is it possible to
> > deadlock?
> 
> At least gnome_idle_monitor_get_idletime is a synchronous call.

Right, we need to fix that instead.
Comment 6 Giovanni Campagna 2013-09-02 18:04:04 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > But the IdleMonitor DBus API is completely async, how is it possible to
> > > deadlock?
> > 
> > At least gnome_idle_monitor_get_idletime is a synchronous call.
> 
> Right, we need to fix that instead.

Or even better, now that I think of it, would be to change the semantics of add_idle_watch() to fire immediately if the watch is for a lower idle time than current. That way, we don't need to check the idletime before installing the watch (which is inherently racy)
Comment 7 Cosimo Cecchi 2013-09-02 18:21:22 UTC
(In reply to comment #2)

> First: *thank you* for finding this bug!  It's been annoying me a while in
> gnome-ostree.  Great commit message diagnosis.  

Hehe yeap this one took a while to find! 

> The fix looks plausible, but the regression happened when gnome-desktop's
> GnomeIdleMonitor was changed to synchronously call into mutter, and I think we
> should also fix it there.

I agree that the sync call in gnome-desktop should probably be fixed with a better solution, but I think this patch is actually correct in any case. The process waiting for registration (in this case Mutter) won't move to the next phase until the reply is received, and gnome-session shouldn't move to the next phase until it sent replies to all the clients waiting, especially since switching session phase will potentially execute a lot of code before we get to sending the reply.
Comment 8 Giovanni Campagna 2013-09-02 18:57:16 UTC
Created attachment 253900 [details] [review]
GsmPresence: don't check the idletime after adding an idle watch

Mutter now does it internally. And this way we avoid a sync dbus
call (which can happen at bad times, such as when mutter is blocking
on us to reply XSMP or DBus)

This one is the other side of the story, and avoids gnome-session
blocking on mutter (which could still block on gnome-session for
other reasons). Depends on bug 707302.
Still I agree it makes sense to merge both.
Comment 9 Ray Strode [halfline] 2013-09-03 12:47:55 UTC
Review of attachment 253900 [details] [review]:

makes sense to me pending the mutter change.
Comment 10 Ray Strode [halfline] 2013-09-03 12:51:58 UTC
Comment on attachment 253815 [details] [review]
manager: fix deadlock when registering XSMP clients at login

Attachment 253815 [details] pushed as 6c24fcc - manager: fix deadlock when registering XSMP clients at login
Comment 11 Matthias Clasen 2013-09-08 15:58:03 UTC
Is there more that we want to commit here, for 3.10 ?
Comment 12 Giovanni Campagna 2013-09-08 16:15:52 UTC
(In reply to comment #11)
> Is there more that we want to commit here, for 3.10 ?

I think getting the mutter fix and the gnome-session counterpart are worthwhile, it avoids a sync dbus call, which is always a good thing.
Comment 13 Giovanni Campagna 2013-09-16 20:45:01 UTC
Attachment 253900 [details] pushed as 8d60892 - GsmPresence: don't check the idletime after adding an idle watch