Dear Maintainer,
On the X11 session with the NVIDIA driver, every shutdown or reboot
started from the Plasma menu stalls until plasma-kwin_x11.service hits
its stop timeout (90 s by default). Everything else in the shutdown
finishes within about two seconds.
Cause
-----
plasma-shutdown (startkde/plasma-shutdown/shutdown.cpp, lines 151-171
in 6.3.6) calls StopUnit on the session target and, as soon as that
D-Bus call returns, asks logind to power off. StopUnit returns when the
job is enqueued, not when the units have stopped. logind then stops the
session scope, which kills sddm-helper, and sddm tears down the X server
while kwin_x11 is still handling its SIGTERM with a live GL context.
kwin_x11 loses the X connection inside the GLX teardown, prints
"XIO: fatal IO error" and never exits, so the user manager waits for
TimeoutStopSec and SIGKILLs it.
journalctl -b -1 from an affected shutdown (TimeoutStopSec lowered to
30 s here; the default is 90 s):
23:15:24 dbus-daemon: Activating 'org.kde.Shutdown' requested by ksmserver-logout
23:15:24 systemd[2406]: Stopped target plasma-workspace.target
23:15:24 systemd[2406]: Stopping plasma-kwin_x11.service - KDE Window Manager...
23:15:24 systemd[2406]: Stopped target graphical-session.target
23:15:24 systemd-logind: The system will power off now!
23:15:24 systemd[1]: Stopping session-4.scope...
23:15:24 sddm-helper: Signal received: SIGTERM
23:15:24 sddm: Display server stopping...
23:15:24 kwin_x11: The X11 connection broke: I/O error (code 1)
23:15:24 kwin_x11: XIO: fatal IO error 4 (Interrupted system call) on X server ":0"
23:15:54 systemd[2406]: plasma-kwin_x11.service: State 'stop-sigterm' timed out. Killing.
23:15:54 systemd[2406]: plasma-kwin_x11.service: Killing process 2712 (kwin_x11) with signal SIGKILL.
23:15:56 systemd-shutdown[1]: Syncing filesystems and block devices.
The same signature is KDE bug 501433 (filed against kwin, but the
trigger is in plasma-shutdown) and sddm issues #1783 and #2058. It
affects every trixie user of the X11 session with the NVIDIA driver.
The Wayland session is not visibly affected because kwin_wayland owns
the display, so nothing external kills it mid-stop.
Fix
---
The attached patch makes plasma-shutdown do what "systemctl stop" does:
Subscribe to the user manager, connect to JobRemoved before enqueueing
the stop job, and call logind only once ListJobs reports no pending
jobs. A 10 s fallback timer keeps a unit that ignores SIGTERM from
blocking shutdown; past that point the behaviour is exactly what it is
today. The non-systemd fallback path is unchanged.
The patch has been forwarded upstream as a merge request against the
current stable branch Plasma/6.7:
https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/7012
The 6.3 version attached differs from the upstream MR only in that it
also switches the stopped target from plasma-workspace.target to
graphical-session.target, which upstream did separately in
80f3e0ad8 ("Stop graphical-session.target directly"). That switch is
needed so the units bound via PartOf= (kwin, ksmserver, ...) are part
of the same stop transaction.
Result with the patch applied (4:6.3.6-2 rebuilt locally as
4:6.3.6-2+local1, which is why the package list below shows that
version; default TimeoutStopSec, no drop-ins):
22:23:12.645 systemd[2394]: Stopping plasma-kwin_x11.service - KDE Window Manager...
22:23:12.852 systemd[2394]: Stopped plasma-kwin_x11.service - KDE Window Manager.
22:23:12.861 systemd-logind[1278]: The system will power off now!
22:23:12.870 sddm[1752]: Display server stopping...
22:23:16.518 systemd-shutdown[1]: Syncing filesystems and block devices.
kwin_x11 stops in about 200 ms, logind is called about 10 ms later,
and the whole shutdown takes under 4 s instead of 30 to 90 s. Tested on
both the X11 and the Wayland session on this machine, shutdown and
reboot, logout unaffected.
Once the upstream MR is merged I would like to ask for this to be
considered for a trixie point release, in the same vein as the
existing upstream_*.patch cherry-picks in debian/patches/series.
Hardware: RTX 5060 Ti + RTX 3060, nvidia-driver 590.48.01-1,
nvidia-kernel-open-dkms, nvidia-drm.modeset=1. Session started via
sddm (startplasma-x11).
Workaround in the meantime: systemctl --user edit plasma-kwin_x11.service
and set TimeoutStopSec=3s in [Service].