https://bugs.kde.org/show_bug.cgi?id=524816

            Bug ID: 524816
           Summary: Stalled logout leaves ksmserver in Shutdown state
                    forever; later closeSession() calls silently never
                    reply, making logout permanently unusable
    Classification: Plasma
           Product: plasmashell
      Version First 6.3.6
       Reported In:
          Platform: Debian stable
                OS: Linux
            Status: REPORTED
          Severity: major
          Priority: NOR
         Component: Session Management
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: 1.0

DESCRIPTION
A single stalled logout attempt leaves ksmserver permanently in the Shutdown
state. All subsequent logout attempts then silently do nothing: the
confirmation dialog appears but confirming has no effect, because
KSMServer::performLogout() (ksmserver/logout.cpp) early-returns when
state >= Shutdown without sending any reply to the D-Bus closeSession()
call:

    if (state >= Shutdown) { // already performing shutdown
        return;              // caller never gets a reply
    }

Additionally the retry branch above it is missing a "return":

    if (state != Idle) {
        QTimer::singleShot(1000, this, &KSMServer::performLogout);
    }
    // execution continues → performLogout() runs twice

On the caller side, plasma-shutdown (plasma-shutdown/shutdown.cpp) calls
closeSession() with setTimeout(INT32_MAX), so it waits forever for a reply
that is never sent. It stays alive holding the D-Bus name org.kde.Shutdown,
after which the logout dialog itself no longer appears on further attempts.

ksmserver exposes resetLogout() (sets state = Idle) but nothing calls it
automatically when a shutdown attempt is aborted. Calling it via D-Bus
(kill the zombie plasma-shutdown first) instantly restores normal logout
behavior, confirming the state machine is the problem.

STEPS TO REPRODUCE
1. Trigger a logout that stalls partway (in my case an unrelated third-party
   systemd unit kept graphical-session.target from stopping, so the shutdown
   never completed; the specific external trigger should not matter).
2. The session keeps running, but ksmserver is now stuck:
   org.kde.KSMServerInterface.isShuttingDown returns true indefinitely and a
   plasma-shutdown zombie process holds org.kde.Shutdown.
3. Attempt logout again: the confirmation dialog appears but confirming does
   nothing (or, once plasma-shutdown holds the bus name, the dialog never
   appears at all). dbus-monitor shows closeSession being called with no
   reply.
4. Kill the plasma-shutdown zombie and call
   org.kde.KSMServerInterface.resetLogout — the next logout works normally.

OBSERVED RESULT
Session becomes permanently unable to log out. Every later closeSession()
is silently dropped (no D-Bus reply), leaving plasma-shutdown hung forever.

EXPECTED RESULT
An aborted shutdown should reset the state machine (or reply
logoutCancelled to the pending caller) so the session stays usable, and
performLogout() should never proceed twice for a shutdown already in
progress (missing return after the singleShot retry).

SOFTWARE/OS VERSIONS
Operating System: Debian GNU/Linux 13
KDE Plasma Version: 6.3.6
KDE Frameworks Version: 6.13.0
Qt Version: 6.8.2
Kernel Version: 6.12.101+deb13-amd64 (64-bit)

ADDITIONAL INFORMATION
Verified against upstream v6.3.6 source: ksmserver/logout.cpp
(performLogout, closeSession, resetLogout) and
plasma-shutdown/shutdown.cpp (startLogout with INT32_MAX timeout).

Suggested fixes:
1. When performLogout() is entered with state >= Shutdown from D-Bus, reply
   to the caller (logoutCancelled) instead of dropping the call; if no
   shutdown is actually in progress, reset state to Idle.
2. Add the missing "return" after the QTimer::singleShot retry.
3. Optionally add a watchdog: if state == Shutdown for several minutes with
   no active shutdown process, automatically call resetLogout().

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to