LightDM login bounces back to greeter after earlyoom kills dbus-daemon
When earlyoom kills dbus-daemon under memory pressure, the user's systemd instance ([email protected]) enters a broken state: all user-level sockets fail with status=219/CGROUP because the cgroup delegation context is corrupt. The next login attempt connects to /run/user/1000/bus — the socket file is still there — but nothing is listening, so dbus-update-activation-environment gets "Connection refused" and xfce4-session (or any DE) crashes immediately. LightDM sees the session exit and returns to the greeter.
The fix-display script (stop lightdm, kill stray X locks, restart lightdm) doesn't help here because the problem isn't an X lock — it's a dead D-Bus.
Diagnosis
cat ~/.xsession-errors
# dbus-update-activation-environment: error: unable to connect to D-Bus:
# Failed to connect to socket /run/user/1000/bus: Connection refused
# /usr/bin/x-session-manager: X server already running on display :0
sudo -u davidw XDG_RUNTIME_DIR=/run/user/1000 systemctl --user list-units --failed
# dbus.service failed
# dbus.socket failed
# pipewire.service failed (and everything else)
Fix
SSH in first. The SSH session lives in session-N.scope, which is a sibling of [email protected] under user-1000.slice — restarting the user manager does not kill your shell.
sudo systemctl restart [email protected]
Then clear the stale X session so LightDM starts a fresh one:
sudo fix-display # or: systemctl stop lightdm && pkill -9 Xorg && rm -f /tmp/.X0-lock && systemctl start lightdm
Log in normally at the console.
Prevention
Add --avoid to earlyoom's config so it skips session-critical processes entirely:
# /etc/default/earlyoom
EARLYOOM_ARGS="-r 3600 --avoid '(^|/)(dbus-daemon|dbus-broker|xfce4-session|systemd|lightdm|sshd)$'"
sudo systemctl restart earlyoom
# confirm: journalctl -u earlyoom -n 3
# Will avoid killing process names that match regex '...'
earlyoom will still intervene under pressure, but it will go after high-OOM-score processes (browser tabs, Electron apps) rather than the session bus.