The timestamps from Sep 1 and Sep 3 are important here. 
Having this exact 90-second delay on both dates shows this is not a random 
crash or an issue with the upgraded packages. It is coming from the systemd 
generator timeout.

I checked the systemd 255 code on my test machine. The error message
"Failed to fork off sandboxing environment" is misleading:

- In manager_execute_generators(), systemd sets an alarm timer for 90
seconds (alarm(90)) before running the generators in parallel.

- If any generator hangs or gets stuck, the 90s timer expires and the
kernel kills the helper process with SIGALRM.

- In process-util.c, when a child process is killed by a signal, systemd
returns the -EPROTO error code ("Protocol error").

- PID 1 receives this error and thinks the sandbox fork failed, so it
freezes the system.

So the sandboxing and namespaces are working fine. The process is simply
killed by the 90-second timer because one generator is hanging.

To stop smb5 from freezing during morning updates while you investigate,
you can tell needrestart not to restart systemd:

Add this line in /etc/needrestart/needrestart.conf:
$nrconf{systemctl_reexec} = 0;

To find which generator is hanging on your test VM, you can run them in
a loop with a short timeout:

sudo mkdir -p /tmp/gen /tmp/gen.early /tmp/gen.late
for g in /usr/lib/systemd/system-generators/*; do
    [ -x "$g" ] || continue
    echo -n "Checking $(basename "$g")... "
    timeout 5s "$g" /tmp/gen /tmp/gen.early /tmp/gen.late >/dev/null 2>&1 && 
echo "ok" || echo "TIMEOUT/FAILED"
done

You can also turn on debug logging before a reload:

sudo systemd-analyze log-level debug

sudo systemctl daemon-reload

sudo systemd-analyze log-level info

Then check journalctl for the last generator printed before the 90s
freeze.

Because this host has SSSD and SMB/NFS storage, my main suspects are
rpc-pipefs-generator (blocking on an unavailable NFS mount in fstab) or
postfix-instance-generator (hanging on NSS lookups if SSSD is restarting
during updates). Once you find it, you can mask it with a symlink to
/dev/null in /etc/systemd/system-generators/ just like you did with gpt-
auto.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2165295

Title:
  systemd freezes after daemon-reexec triggered by unattended-upgrades /
  needrestart on Ubuntu 24.04

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2165295/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to