-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: undocumented breaking change in exec.Command behavior on Windows between Go versions 1.16.8 and 1.17.1 #48393
Comments
/cc @zx2c4 @alexbrainman |
Is this a duplicate of (or related to) #48040? |
I can submit a patch to make the release notes more clear, I guess? |
Change https://golang.org/cl/350412 mentions this issue: |
I get this impression that this shouldn't be in the 1.18 milestone. Maybe the next 1.17 milestone? (We're currently trying to clear out 1.18 now that we've entered the freeze.) |
I think this was fixed by CL 350416. |
I think the original issue reported here has not been fixed. The release notes still only say: "AdditionalInheritedHandles is a list of additional handles to be inherited by the new child process." The issue being reported here is that prior to go 1.17, all inheritable file handles would be inherited (if NoInheritHandles is false), whereas in 1.17 only stdin/out/err and the handles listed in AdditionalInheritedHandles are inherited. This behavior change is not mentioned anywhere in the release notes. (It also makes it much harder for our go binary that wants to transparently pass all inheritable handles through to the subprocess; I can file a separate issue about that if you'd prefer). |
Agree. The release notes did not get updated. Jason started https://golang.org/cl/350412 but abandoned it. @brianryner8 would you like to change the docs yourself? Here is how to contribute https://go.dev/doc/contribute @bcmills I will reopen this issue. Feel free to close it if you disagree and think the doco is good enough.
I don't think you want every inheritable handle of your parent process to silently be inherited by every child. This will make a lot of unexplained bugs, like "unclosed handles". But please file a new issue, if you still have any bug or suggestion to discuss. Thank you. Alex |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
On Windows, when using
exec.Command
and relying on inheriting handles and using inherited handles in the child process, code that worked when compiled Go 1.16.8 no longer works when compiled with Go 1.17.1.The culprit seems to be the
AdditionalInheritedHandles
attribute introduced in the context of #44011, and particularly the following breaking change: 2d76081#diff-ec673c10a75fe2d2faa9c788e03823294b263c68cc3de50f4a0865a53e28f3a3R340. In Go 1.16, on Windows, child processes inherit all handles marked as inherited. In Go 1.17 the handles to be inherited have to be explicitly added to theAdditionalInheritedHandles
list.Sample program:
Running this on different versions of Go produces different results:
What did you expect to see?
I expected one of the following:
What did you see instead?
Same code compiled with Go 1.16.8 and Go 1.17.1 exhibits different behavior.
The underlying breaking change in Go's behavior is not clearly marked as such in Go 1.17 release notes. The current document states:
This is misleading and seems to actually be incorrect, as only the handles list in AdditionalInheritedHandles are going to be inherited by the new child process.
The text was updated successfully, but these errors were encountered: