Bug 429415

Summary: kglobalaccel breaks after logging out
Product: [Frameworks and Libraries] frameworks-kglobalaccel Reporter: Fabian Vogt <fabian>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bugseforuns, elman, henri, kde, mpagano, nate, sknauss
Priority: NOR    
Version: 5.77.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Fabian Vogt 2020-11-20 20:38:37 UTC
Due to https://bugs.kde.org/show_bug.cgi?id=424408, everything dies improperly on logout or shutdown:

Nov 20 13:04:10.535450 susetest kded5[1561]: The X11 connection broke (error 1). Did the X11 server die?
Nov 20 13:04:10.575429 susetest kwin_x11[1565]: The X11 connection broke (error 1). Did the X11 server die?
Nov 20 13:04:10.584159 susetest plasmashell[1613]: The X11 connection broke: I/O error (code 1)
Nov 20 13:04:10.586981 susetest kglobalaccel5[1595]: The X11 connection broke (error 1). Did the X11 server die?
Nov 20 13:04:10.589052 susetest kactivitymanagerd[1586]: The X11 connection broke (error 1). Did the X11 server die?
Nov 20 13:04:10.597508 susetest gmenudbusmenuproxy[1630]: The X11 connection broke (error 1). Did the X11 server die?
Nov 20 13:04:10.605577 susetest kaccess[1615]: The X11 connection broke (error 1). Did the X11 server die?
Nov 20 13:04:10.605856 susetest xembedsniproxy[1619]: The X11 connection broke (error 1). Did the X11 server die?
Nov 20 13:04:10.648612 susetest org_kde_powerdevil[1636]: The X11 connection broke (error 1). Did the X11 server die?
Nov 20 13:04:10.693440 susetest systemd[1441]: plasma-kglobalaccel.service: Succeeded.

For some reason, plasmashell does a dbus call on exit:

Nov 20 13:04:10.802549 susetest dbus-daemon[1461]: [session uid=1000 pid=1461] Activating via systemd: service name='org.kde.kglobalaccel' unit='plasma-kglobalaccel.service' requested by ':1.23' (uid=1000 pid=1613 comm="/usr/bin/plasmashell ")

This triggers a restart of kglobalaccel:

Nov 20 13:04:10.810195 susetest systemd[1441]: Starting KDE Global Shortcuts Server...

The display is gone though, so:

Nov 20 13:04:11.261120 susetest kglobalaccel5[15686]: qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
Nov 20 13:04:11.287405 susetest kglobalaccel5[15686]: Failed to create wl_display (No such file or directory)
Nov 20 13:04:11.289301 susetest kglobalaccel5[15686]: qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
Nov 20 13:04:11.289452 susetest kglobalaccel5[15686]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
                                                      
                                                      Available platform plugins are: wayland-org.kde.kwin.qpa, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Nov 20 13:04:11.345485 susetest systemd[1441]: plasma-kglobalaccel.service: Main process exited, code=dumped, status=6/ABRT
Nov 20 13:04:11.346067 susetest systemd[1441]: plasma-kglobalaccel.service: Failed with result 'core-dump'.
Nov 20 13:04:11.346567 susetest systemd[1441]: Failed to start KDE Global Shortcuts Server.

Ultimately, it wedges itself, needing manual help:

Nov 20 13:04:12.748039 susetest systemd[1441]: plasma-kglobalaccel.service: Scheduled restart job, restart counter is at 5.
Nov 20 13:04:12.748079 susetest systemd[1441]: Stopped KDE Global Shortcuts Server.
Nov 20 13:04:12.748165 susetest systemd[1441]: plasma-kglobalaccel.service: Start request repeated too quickly.
Nov 20 13:04:12.748174 susetest systemd[1441]: plasma-kglobalaccel.service: Failed with result 'core-dump'.
Nov 20 13:04:12.748315 susetest systemd[1441]: Failed to start KDE Global Shortcuts Server.

On the next login, this service is thus not starting and thus Plasma doesn't work properly:

Nov 20 13:04:52.893267 susetest kwin_x11[15860]: Couldn't start kglobalaccel from org.kde.kglobalaccel.service: QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")

Downstream report (found by openQA): https://bugzilla.opensuse.org/show_bug.cgi?id=1179033
Comment 1 Fabian Vogt 2020-11-20 20:39:51 UTC
This is probably "caused" by "systemd dbus activation".
Comment 2 Fabian Vogt 2020-12-07 11:32:27 UTC
A definitely related merge request was started: https://invent.kde.org/frameworks/kglobalaccel/-/merge_requests/10
Comment 3 David Edmundson 2020-12-18 17:29:57 UTC
Git commit 25e84f3f6ac54097d9c021705dc18b187352fa02 by David Edmundson.
Committed on 18/12/2020 at 17:29.
Pushed by davidedmundson into branch 'master'.

Avoid autostarting kglobalaccel when shutting down

Order of our service teardown is somewhat undefined. kglobalaccel5 can
be closed before plasmashell.

On plasma exit we call setInactive/unregister on various kglobalaccel
actions and accidentally spawn kglobalaccel again.

If kglobalaccel is already closed, our actions aren't registered. There
is no point waking it up to try and remove an action. Use of the
setAutoStartService flag was chosen over checking if the kglobalaccel
service is still registered as that is still racey.

This was always slightly broken, but changes in the ecosystem means the
effect has worsened.

M  +25   -3    src/kglobalaccel.cpp
M  +3    -0    src/kglobalaccel_p.h

https://invent.kde.org/frameworks/kglobalaccel/commit/25e84f3f6ac54097d9c021705dc18b187352fa02
Comment 4 Sandro Knauß 2020-12-29 22:30:23 UTC
(In reply to David Edmundson from comment #3)
> Git commit 25e84f3f6ac54097d9c021705dc18b187352fa02 by David Edmundson.
> Committed on 18/12/2020 at 17:29.
> Pushed by davidedmundson into branch 'master'.

I've adding this patch on top of 5.56.0 and tested it. But systemd is still restarting kglobalaccel: while shutting down the computer:

Dez 29 22:48:12 xxx systemd[1]: Stopping Session 3 of user Me
Dez 29 22:48:12 xxx systemd[5622]: plasma-kglobalaccel.service: Main process exited, code=exited, status=1/FAILURE
Dez 29 22:48:12 xxx systemd[5622]: plasma-kglobalaccel.service: Failed with result 'exit-code'.
Dez 29 22:48:12 xxx systemd[5622]: plasma-kglobalaccel.service: Scheduled restart job, restart counter is at 1.
Dez 29 22:48:12 xxx systemd[5622]: Stopped KDE Global Shortcuts Server.
Dez 29 22:48:12 xxx systemd[5622]: Starting KDE Global Shortcuts Server...
Dez 29 22:48:12 xxx kglobalaccel5[12379]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Dez 29 22:48:12 xxx kglobalaccel5[12379]: Available platform plugins are: wayland-org.kde.kwin.qpa, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-eg>
Dez 29 22:48:12 xxx systemd[5622]: plasma-kglobalaccel.service: Main process exited, code=killed, status=6/ABRT
Dez 29 22:48:12 xxx systemd[5622]: plasma-kglobalaccel.service: Failed with result 'signal'.
Dez 29 22:48:12 xxx systemd[5622]: Failed to start KDE Global Shortcuts Server.
Comment 5 Fabian Vogt 2020-12-30 12:36:51 UTC
(In reply to Sandro Knauß from comment #4)
> (In reply to David Edmundson from comment #3)
> > Git commit 25e84f3f6ac54097d9c021705dc18b187352fa02 by David Edmundson.
> > Committed on 18/12/2020 at 17:29.
> > Pushed by davidedmundson into branch 'master'.
> 
> I've adding this patch on top of 5.56.0 and tested it. But systemd is still
> restarting kglobalaccel: while shutting down the computer:
> 
> Dez 29 22:48:12 xxx systemd[1]: Stopping Session 3 of user Me
> Dez 29 22:48:12 xxx systemd[5622]: plasma-kglobalaccel.service: Main process
> exited, code=exited, status=1/FAILURE
> Dez 29 22:48:12 xxx systemd[5622]: plasma-kglobalaccel.service: Failed with
> result 'exit-code'.
> Dez 29 22:48:12 xxx systemd[5622]: plasma-kglobalaccel.service: Scheduled
> restart job, restart counter is at 1.

That seems like a slightly different issue - kglobalaccel exits with 1, so systemd tries to restart it. Question is why it exits with 1.
Comment 6 Fabian Vogt 2021-01-06 15:40:26 UTC
*** Bug 430736 has been marked as a duplicate of this bug. ***
Comment 7 Nate Graham 2021-02-24 04:59:13 UTC
*** Bug 431154 has been marked as a duplicate of this bug. ***
Comment 8 Nate Graham 2021-04-12 17:33:10 UTC

*** This bug has been marked as a duplicate of bug 429426 ***