mirror of
https://github.com/systemd/systemd.git
synced 2026-08-12 22:17:19 +00:00
The existing alias-corruption subtest only intermittently caught the regression where unit_deserialize_state_skip() stopped at the first empty line and thus failed to consume embedded "job" subsections (written by job_serialize() when u->job or u->nop_job is non-NULL). This same skip routine is also used by the pre-scan that builds the set of serialized unit names (added ina77c7a8224to detect stale alias state). When skip terminates early at a job's end marker, the scan desyncs and every subsequent unit name is dropped from the set, silently bypassing the alias-corruption protection for those units. Whether the bug fired depended on: 1. Whether any unit happened to carry a pending job at the moment of reload/reexec (mostly chance, depends on timers, transient units, load, etc.). 2. Hashmap iteration order during serialization (per-boot randomized siphash seed) determining if a job-bearing unit was written before a sus-NN.service alias. To try and make the regression deterministic, add a "with_pending_jobs" mode that creates 50 Type=oneshot services and starts them with systemctl --no-block. Each remains in "activating" state with u->job set forever, guaranteeing the serialized stream contains many embedded job subsections regardless of hashmap order, and that at least one of them precedes the sus units. Without the fix, the desync drops the sus-NN entries from the set, the alias-corruption check set_contains(serialized_units, u->id) returns false for every alias, and legit.service's MainPID is overwritten on every run. Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com> (cherry picked from commita1aed3eae2) (cherry picked from commit0316f75782)