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: calling Cmd.Start after setting Cmd.Path manually to absolute path without ".exe" no longer implicitly adds ".exe" in Go 1.22 #66586
Comments
@gopherbot please backport go1.22 |
Backport issue(s) opened: #66598 (for 1.22). 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/575255 mentions this issue: |
Change https://go.dev/cl/575275 mentions this issue: |
This issue was reviewed in the release meeting. Is there any status update to report on this issue? |
@dmitshur I see the CL was abandoned, is this issue also obsolete? |
@joedian It was a draft CL associated with a review comment. Russ has go.dev/cl/575255 which is still open but needs attention. |
For avoid data race for cmd.Path , in CL 527820 fixed data race , but addition of suffixe as shown in golang#66586 was also introduced. The result of call lookExtensions is actually the name passed to os.StartProcess, But solutions at the time chose to reuse cmd.Path to represent the name passed to os.StartProcess,since this results in golang#66586, So use new field save call lookExtensions result. Fixes golang#66586 Change-Id: Ib1baa6d7803f9471af6e38bcb55f0298422e6743
Change https://go.dev/cl/581695 mentions this issue: |
https://go.dev/doc/go1.22#os/exec includes:
I don't quite understand what criteria is used for determining whether a path has an executable file extension. Which extensions are included? Is the
PATHEXT
environment variable involved?That said, I've narrowed down a following behavior change between Go 1.21 and 1.22 that I'm not sure if it's working as intended, so reporting it for investigation.
Consider the output of the following Go program on a Windows machine that has an executable file at the path "C:\Program Files\Go\bin\gofmt.exe", in a roughly default environment (i.e.,
PATHEXT
is not modified):When running it using Go 1.21.8, the output is:
But when running it with Go 1.22.1:
Not having to manually add ".exe" to the path and instead relying on the
PATHEXT
mechanism is very convenient when writing multi-platform Go programs, since it permits there not to be special cases for one of the GOOS values.In that context, it seems there's no change in behavior when using
exec.Command
to create a*exec.Cmd
and then callingCmd.Start
on it. But when creating it manually, Go 1.21 would usePATHEXT
compensate forCmd.Path
missing a ".exe" suffix, whereas Go 1.22 doesn't. I can't quite tell from os/exec documentation (or the seemingly relevant release note) if this is a bug fix or a bug.CC @golang/windows.
The text was updated successfully, but these errors were encountered: