This issue was fixed upstream by commit 5c1137ec2 ("cinnamon-launcher: use
os.WIFEXITED to interpret the status code when cinnamon exits.",
2021-11-25).
The cause was in /usr/bin/cinnamon-launcher: the exit status returned by
os.waitpid() is an encoded wait status, not a plain exit code, but it was
checked with "if exit_status != 0". At the end of the session cinnamon
terminates normally, yet that check treated it as a crash, so the launcher
entered its crash-recovery path: it forked the metacity fallback session,
started the fallback helpers (polkit agent, nm-applet) and popped up the
"Cinnamon just crashed" dialog. As a result cinnamon-launcher kept running
inside session-N.scope, and systemd waited for its 90 seconds stop timeout
before SIGKILLing it - the "A stop job is running for session N of user X"
message reported here. This also explains why killing cinnamon-launcher by
hand, or logging out before shutting down, avoided the delay, and why no
crash or segfault was visible in the logs.
The fix is included upstream since 5.2.1, and in Debian since cinnamon
5.2.6-1 (experimental) and 5.2.7-2 (unstable, uploaded on 2022-01-26).
All currently supported suites therefore carry it: bookworm (5.6.x),
trixie (6.4.10) and unstable (6.6.9-1).
Closing this bug and #1002832, which was merged with it.
If anyone still runs into a similar shutdown or logout delay on a current
version, please do not reopen this bug: the cause described above is gone,
so the same symptom now would have a different root cause and needs to be
tracked separately. Please file a new report instead, including:
- the exact versions of cinnamon and cinnamon-session;
- the output of "journalctl -b -1" around the "A stop job is running"
message, showing which processes are killed and in which scope/unit;
- whether the delay also happens with a newly created user account;
- whether logging out first and then shutting down from the login manager
avoids it.
Thanks to everyone who reported and helped debugging this.