-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
os/exec: resource leak on exec failure #69284
Comments
This is a regression in Go 1.23.0. I've bisected it to commit 2f64268, introduced by this CL https://go-review.googlesource.com/c/go/+/570036/ |
Looks like a bug in
but this program prints "PidFD set on failure", which seems wrong
|
CC @bradfitz, @ianlancetaylor. |
CC @kolyshkin |
@rogpeppe I don't think your program is buggy. The program does get a valid pidfd that refers to the child. It's true that the child exits immediately because the exec failed. That just means that the pidfd refers to the zombie process. |
Change https://go.dev/cl/611217 mentions this issue: |
I'd say it's buggy because the behaviour does not conform to the documentation. The docs say "PidFD is changed only if the process starts successfully". The process did not start successfully, but |
@rogpeppe Thanks, I see what you mean. I wasn't quite grasping that |
Change https://go.dev/cl/611495 mentions this issue: |
Is the plan to backport this to Go 1.23.x? |
@gopherbot Please open a backport issue to 1.23. This causes os/exec to leak file descriptors when used to run a non-existent file on Linux. There is no simple workaround. |
Backport issue(s) opened: #69402 (for 1.23). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/613616 mentions this issue: |
For #69284 Fixes #69402 Change-Id: I6350209302778ba5e44fa03d0b9e680d2b4ec192 Reviewed-on: https://go-review.googlesource.com/c/go/+/611495 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: roger peppe <[email protected]> Reviewed-by: Tim King <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> (cherry picked from commit 8926ca9) Reviewed-on: https://go-review.googlesource.com/c/go/+/613616 Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Tobias Klauser <[email protected]>
For golang#69284 Fixes golang#69402 Change-Id: I6350209302778ba5e44fa03d0b9e680d2b4ec192 Reviewed-on: https://go-review.googlesource.com/c/go/+/611495 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: roger peppe <[email protected]> Reviewed-by: Tim King <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> (cherry picked from commit 8926ca9) Reviewed-on: https://go-review.googlesource.com/c/go/+/613616 Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Tobias Klauser <[email protected]>
Go version
go version go1.23.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
It seems that when
process.Start
fails, there are some files left open, which after a while leads to a "too many open files" error.Here's a minimal repro:
What did you see happen?
The test fails with:
What did you expect to see?
I expected the test to pass.
Note that the issue occurs also on other
exec
failures, such as permission denied, invalid ELF format, etc.The text was updated successfully, but these errors were encountered: