-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trailing backslash causes infinite loop in quadlet generator #24810
Comments
@ygalblum PTAL |
I like the idea of adding a timeout. As you wrote, we have seen (and probably see) parsing issues causing infinite loops. The change is not even that big and it does seem to be working in my branch. |
There is never a right "timeout", I mean for quadlet we are only parsing small files so we should assume that it runs quick in all cases but is hard to say what quick is exactly. It is certainly an easy fix to guard against other bugs like this but overall I would say we should investigate why we have endless loops in a "simple" file parser and spend time rewriting the code in a way that makes infinitive loops impossible. That said I do acknowledge that might not be an easy task and a timeout is a easy thing we can do to improve things. If we are run from systemd does it kill us after a set timeout on their end or does the quadlet process just keeps running forever? If we are not killed I think systemd generally seems to use 90s as default timeout so maybe this seems reasonable? |
Yes, I agree that catching these errors and fixing them is the right thing to do. But, we can see that there's always another use case we did not cover. Since this is not a fix for the issue but instead a workaround for infinite loops, once a timeout occurs, users will report this (we can also ask them to in the log message). As for current timeouts, according to the issue description, Quadlet was triggered via Regarding reasonable timeout, I agree, it's always a problem. So, I would choose an unreasonably long one, say 10 minutes. |
This commit simplifies the systemd parser logic, and it solves an infinite loop when using a continuation line. Closes: containers#24810 Signed-off-by: Giuseppe Scrivano <[email protected]>
This commit simplifies the systemd parser logic, and it solves an infinite loop when using a continuation line. Closes: containers#24810 Signed-off-by: Giuseppe Scrivano <[email protected]>
using a timeout to guard issues in a "simple" parser, seems overkilling to me. I ended up with a simpler implementation while taking a look at the issue, and I've opened a PR: #24825 The tests were focused on recreating exactly the same input, which I don't think has much value, so I've simplified that too. |
This commit simplifies the systemd parser logic, and it solves an infinite loop when using a continuation line. Closes: containers#24810 Signed-off-by: Giuseppe Scrivano <[email protected]>
This commit simplifies the systemd parser logic, and it solves an infinite loop when using a continuation line. Closes: containers#24810 Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe thanks for looking into this. I agree that removing the loop Quadlet keeps on getting stuck on is the correct fix. I'll put aside my timeout implementation. |
This commit simplifies the systemd parser logic, and it solves an infinite loop when using a continuation line. Closes: containers#24810 Signed-off-by: Giuseppe Scrivano <[email protected]>
This commit simplifies the systemd parser logic, and it solves an infinite loop when using a continuation line. Closes: containers#24810 Signed-off-by: Giuseppe Scrivano <[email protected]>
This commit simplifies the systemd parser logic, and it solves an infinite loop when using a continuation line. Closes: containers#24810 Signed-off-by: Giuseppe Scrivano <[email protected]>
This commit simplifies the systemd parser logic, and it solves an infinite loop when using a continuation line. Closes: containers#24810 Signed-off-by: Giuseppe Scrivano <[email protected]>
Thanks! I’m also in favour of simplifying being an entirely valid mitigation here. Replacing |
Issue Description
When an exec line ends with a trailing backslash, the quadlet generator enters an infinite loop and never returns.
Steps to reproduce the issue
I can reproduce this on
podman-5.3.0-1.fc41.x86_64
, or from 07dddeb (latestmain
at time of writing)./etc/containers/systemd/breakstuff.container
:/usr/lib/systemd/system-generators/podman-system-generator
(orcmd/quadlet/main.go
)Describe the results you received
The
podman-system-generator
(quadlet
) process never terminates, and uses 100% CPU:Describe the results you expected
I would expect a parse error to occur, or at least some kind of timeout.
By the time I noticed this issue, there were many copies of
podman-system-generator
running on my system, as a new copy is spawned with eachsystemctl daemon-reload
.While user error is what triggers this (due to bad syntax), it should fail gracefully. This class of problem has occurred elsewhere in #21109 and #22974, which makes me wonder whether this is worth additionally mitigating by introducing some kind of timeout, e.g. doing the work in a goroutine, which is raced against a timer (could be quite long, e.g. order of minutes).
podman info output
Podman in a container
No
Privileged Or Rootless
None
Upstream Latest Release
Yes
Additional environment details
Reproduced on Fedora 41 (amd64).
Additional information
No response
The text was updated successfully, but these errors were encountered: