When my Xubuntu 18.04 laptop resumes from suspend, systemd-logind automatically logs out of the current session if the laptop has stayed suspended for more than a couple of hours. If the interval between suspend and resume is short, it doesn't log out. I still haven't discovered how long this interval has to be in order to cause the logout.
I enabled debug on the systemd-logind.service, creating file /etc/systemd/system/systemd-logind.service.d/10-debug.conf:
[Service]
Environment=SYSTEMD_LOG_LEVEL=debug
which causes systemd-logind to log all D-Bus messages it handles, but couldn't spot anything that might have caused the logout.
I scanned all systemd journal messages (journalctl
) before systemd-logind starts killing the current session, investigated all that looked suspicious but couldn't find anything that might influence an automatic logout. Here are some of the messages that striked me as suspicious (they are not sequential, but pulled from different occasions):
upowerd[1600]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0
polkitd(authority=local)[840]: Unregistered Authentication Agent for unix-session:c2 (system bus name :1.46, object path /org/gnome/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
wpa_supplicant[811]: dbus: fill_dict_with_properties dbus_interface=fi.w1.wpa_supplicant1.Interface dbus_property=Stations getter failed
wpa_supplicant[811]: dbus: wpa_dbus_get_object_properties: failed to get object properties: (none) none
at-spi-bus-launcher[7031]: XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
at-spi-bus-launcher[7031]: after 30333 requests (30333 known processed) with 0 events remaining.
systemd-logind[779]: Inhibitor xfce4-power-manager (xfce4-power-manager handles these events) pid=8611 uid=1000 mode=block stopped
systemd-logind[779]: Electing new display for user paulo
systemd-logind[779]: Ignoring session c8
logind config doesn't have anything that might cause this:
paulo:~$ loginctl show-session
EnableWallMessages=no
NAutoVTs=6
KillUserProcesses=no
RebootToFirmwareSetup=no
IdleHint=no
IdleSinceHint=0
IdleSinceHintMonotonic=0
BlockInhibited=handle-power-key:handle-suspend-key:handle-hibernate-key
DelayInhibited=sleep
InhibitDelayMaxUSec=5s
HandlePowerKey=poweroff
HandleSuspendKey=suspend
HandleHibernateKey=hibernate
HandleLidSwitch=suspend
HandleLidSwitchDocked=ignore
HoldoffTimeoutUSec=30s
IdleAction=ignore
IdleActionUSec=30min
PreparingForShutdown=no
PreparingForSleep=no
Docked=no
RemoveIPC=yes
RuntimeDirectorySize=615313408
InhibitorsMax=8192
NCurrentInhibitors=5
SessionsMax=8192
NCurrentSessions=1
UserTasksMax=10813
I can't find any anything that might cause an automatic logout after a time interval. I'm really stumped.
For intermittent X crash with SIGBUS on 18.04, please check this answer:
Ubuntu 18.04 error on waking up from sleep : Read-error on swap device
I have confirmed that this issue is caused by the Xorg server crashing with SIGBUS. Xorg server crashes and systemd-logind creates a new login session.
The Xorg server crashes because of an excessive number of requests from at-spi-bus-launcher. Right before each crash, messages such as these were logged on the systemd journal:
It seems to be a documented issue, that Xorg crashes when it receives an excessive number of requests without interval.
To work around this bug, 2 steps are necessary:
at-spi2-core
export NO_AT_BRIDGE=1
to .profile, so that GTK applications don't complain about the absence of the accessibility busXorg never crashed anymore after this workaround, and consequently there was no automatic logout anymore after resuming from suspend.
I filed a bug report against at-spi on the Gnome BugZilla.
When I think I nailed this issue, it bites me again :-(. The issue itself is indeed caused by the Xorg server crashing with SIGBUS, but the root cause of the crash is not at-spi-bus-launcher misbehaving. It shouldn't loop making those repeated requests, so the previous procedure is still valid, although it's not a workaround to the Xorg crash.
I discovered that Xorg was using kernel driver i915:
So I tried another workaround, to force Xorg to use
xserver-xorg-video-intel
with acceleration method uxa, which is more stable than the default sna.Here's /etc/X11/xorg.conf.d/10-intel.conf:
I have been using this workaround for 1 week and the Xorg server hasn't crashed, so I get the impression that it's the definitive workaround while Xorg isn't fixed.
I've opened a bug report against Xorg, which apparently seems to be affecting more users, since it was flagged as a duplicate of another bug, which I didn't detect at first since its title mentions another type of crash.
For those who are still facing this issue, here is my experience. Nvidia driver was the issue. On Linux Kernel version 5.0.0-27, "logout when resuming from suspend" started after I installed the Nvidia driver.
After a lot of failed "fixes" (listed here and elsewhere), I disabled the nvidia using the prime-select tool. And my laptop wakes up and restores session now. I have tested enabling/disabling nvidia and can safely conclude this is a workaround.
I'd still like to use nvidia though.
Here is the 10 lines before and after the said I/O Error-