-
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: cmd.Output/StartProcess hangs on macOS 12.3 #52086
Comments
It's possible #52226 is related. It's also a hang on |
Yeah I'm just surprised how I'm able to reproduce this bug |
@dprotaso Try building with |
I'm encountering a similar issue as reported here, and was able to reproduce on Golang v1.18.4. I don't have a small enough reproduction case to share here yet, but I did grab similar (but not identical) golang stack traces from the parent process and OS X process samples from the child process. Similar to @dprotaso, the hang only reproduces when the I was not able to test CGO_ENABLED=0 as @lpusok suggested, as the tool being compiled in my case requires CGO for core functionality it has. Golang parent process golang stack trace
OS X process samplesactual print binary name replaced with
|
Reproducing the hangI was able to make a ~32 line snippet that reproduces this issue about once every 1200 invocations using golang v1.18.4 on my Apple Arm based M1 device, running OS X Monterrey 12.4: I was seemingly able to reproduce the issue more frequently before removing several channels and time based selects, but go build .;
for i in (seq 1 100000);
echo "Iteration $i";
./repro-52086;
end; Process State After ReproductionWhen the for loop stops printing, if you look at the process statuses with something like Child ProcessThe child process will be using 95%+ CPU and if you find the process in OS X Activity Monitor, and take a sample, the trace will look something like:
Parent ProcessThe parent process will be using 0% cpu and have a sampled trace in the OS X activity monitor of something like
Important setup caveatsThe environment variable If you are using iTerm 2 or Alacritty as your terminal I've confirmed that this reproduction case works on both Apple Terminal (once |
I think this failure looks quite similar. |
Still encountering this with macOS 12.6.1 and go1.19.3 darwin/amd64 |
Very weird. If you are comfortable building Go from source, please try commit 1f4394a, which I just checked in. If not, wait for Go 1.20rc1. |
I think the change works - I'll run it overnight to confirm. Before it failed maybe 1 in 20 runs. I just ran it ~100 times and no issues. |
Sounds like this is a duplicate of #56784 then. Please close when you are satisfied it's gone. |
Ran it 1000 times and didn't see it reproduce. Thanks for the fix! |
Does it make sense to cherry pick this fix back? |
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
)?OS: macOS Monterey Version 12.3 (21E230)
Arch: amd64 (Intel i9)
Bash: GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin20.6.0)
KO_DOCKER_REPO set to a gcr repo - but I've reproduced this using kind.local as well (see kind setup)
Terminal: iTerm2 Build 3.4.15
go env
OutputWhat did you do?
What did you expect to see?
The
ko
program uses theos/exec.Cmd
package to kick off go builds and perform registry credential lookups.The program runs to completion
What did you see instead?
The program hangs calling
cmd.Output()
. It looks like it a fork/exec fails asps -l
it shows the forked process but it looks like exec wasn't invoked as the process name is the same.After some time the process state was
Parent Process Stack Dumps
Go routine stack traces for the parent and child process are here: https://gist.github.com/dprotaso/1e1c4c2abea19dbfbdbb61b221c0fdcc
Notes on reproducibility
I wasn't able to reproduce this in
zsh
onlybash
Using Apple's Terminal.app I couldn't reproduce the issue (~10 runs). Comparing the difference between the terminal apps I noticed iTerm had some extra env vars.
I figured out an env var having an affect.
__CF_USER_TEXT_ENCODING
. Setting this did causeko
in Apple's Terminal.app to start hangingAfter unset'ing that env var in iTerm I didn't encounter a hang (20 tries)
Unsure how that envvar has an affect on fork/exec
The text was updated successfully, but these errors were encountered: