OnFailure resolving can trigger infinite loop
Open
Nobody has claimed this yet.
pid1
- Dominant language
- C
- Stars
- 16.7k
- Forks
- 4.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 140
Description
It is possible to create an infinite loop in the systemd resolver for the OnFailure unit.
This can be reproduced by running the following script in a login session:
mkdir -p ~/.config/systemd/user
cd ~/.config/systemd/user
cat >a.target <<%EOF
[Unit]
OnFailure=b.target
Requisite=d.target
%EOF
cat >b.target <<%EOF
[Unit]
Requires=c.target
%EOF
cat >c.target <<%EOF
[Unit]
Wants=a.target
%EOF
cat >d.target <<%EOF
[Unit]
%EOF
journalctl -f &
systemctl --user daemon-reload
systemctl --user start c.target &
sleep 1
killall -9 systemd
This results in a lot of messages like:
Apr 19 21:10:42 ben-x1 systemd[13163]: Dependency failed for a.target.
Apr 19 21:10:42 ben-x1 systemd[13163]: Dependency failed for a.target.
Apr 19 21:10:42 ben-x1 systemd[13163]: a.target: Job a.target/start failed with result 'dependency'.
Apr 19 21:10:42 ben-x1 systemd[13163]: a.target: Job a.target/start failed with result 'dependency'.
Apr 19 21:10:42 ben-x1 systemd[13163]: a.target: Triggering OnFailure= dependencies.
Apr 19 21:10:42 ben-x1 systemd[13163]: a.target: Triggering OnFailure= dependencies.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the loop with the unit files and commands in the issue, then watch the repeated messages with journalctl while starting c.target through systemctl --user. Trace the systemd dependency and OnFailure resolution involved in the reproduction. Done means the same unit graph no longer produces unbounded repeated failure and OnFailure messages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100