cgo: hang on race condition between cmd.Run() and DNS lookup on macOS #54061
Labels
FrozenDueToAge
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
What version of Go are you using (
go version
)?Also present on older versions (tested on
go1.16
andgo1.17.11
as well).Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?Easily reproducible (after a few tries) on macOS Monterey (both on ARM and Intel-based CPUs, tried on both macOS 12.2 and 12.4).
go env
OutputWe couldn't reproduce it on Linux (
Ubuntu 20.04
) and macOS Catalina (10.15.7
) but we could very infrequently reproduce it on macOS Big Sur (11.6.8
) as well.What did you do?
Run https://go.dev/play/p/3gaoK8kU6Qb on macOS Monterey via
for i in {1..100}; do go run main.go; echo $i; done
, it usually hangs after ~10 runs.What did you expect to see?
The command execution and HTTP request-related goroutines terminate, the main goroutine terminates, and the process exits.
What did you see instead?
The process hangs forever, doesn't terminate.
It (the main, parent process) is consuming 100% CPU.
On
cmd.Run()
it succesfullyfork
-ed the parent process but the child neverexecve
-ed (it still points to the parent process's binary).Stacktrace of hung process.
dtruss
on the parent process doesn't report any syscalls.dtruss
on the child process (created bycmd.Run()
) reports__semwait_signal(0x903, 0x0, 0x1) = -1 Err#60
every few seconds.CGO_ENABLED=0
fixes the issue.cgo
is the default) viaGODEBUG=netdns=go
fixes the issue.unset
-ig the__CF_USER_TEXT_ENCODING
environment variable fixes the issue (similar to/same as os/exec: cmd.Output/StartProcess hangs on macOS 12.3 #52086 ?).The text was updated successfully, but these errors were encountered: