]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine: GC machine when no leader PID is set
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Dec 2024 02:38:24 +0000 (11:38 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 28 Dec 2024 12:03:20 +0000 (12:03 +0000)
After d8854ff1aca4434db0d7d6dcaf9fcf2f38105fb4, if a serialized
leader PID of a machine is already dead when deserialized, then the
leader PID and PIDFD are unset for the machine, and subsequent
machine_start() -> machine_watch_pidfd() will trigger an assertion.
This makes a Machine object without leader PID GCed.

Fixes a bug introduced by the combination of
d8854ff1aca4434db0d7d6dcaf9fcf2f38105fb4 (v255) and
1762c2c045d3a78d3cad54c6b1e5ee9624b32b00 (v257).

Fixes #35602.

src/machine/machine.c

index 7f5f48bd9b156640b053487e6746271a3253a2f1..9edea3dfa47f2443dfed34230d1dc27ff11ac077 100644 (file)
@@ -610,6 +610,9 @@ bool machine_may_gc(Machine *m, bool drop_not_started) {
         if (m->class == MACHINE_HOST)
                 return false;
 
+        if (!pidref_is_set(&m->leader))
+                return true;
+
         if (drop_not_started && !m->started)
                 return true;