x/sys/unix: Workaround xnu
kernel bug when making procargs2
syscall using SysctlRaw
#60047
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
OS-Darwin
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, on macOS Catalina
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Called
unix.SysctlRaw()
to get the args of a process on Catalina (through the use of thegithub.com/elastic/go-sysinfo
package)I have created a small demo test in my fork of
go-sysinfo
that demonstrates the issue. Note: this must be run on macOS Catalina in order to the issue to be reproduced.What did you expect to see?
The
unix.SysctlRaw()
function return the args of a process on Catalina.What did you see instead?
I noticed that using
unix.SysctlRaw()
to call thekern.procargs2
syscall on macOS Catalina does not return the args for a process due to a couple bugs inxnu
:executable_path=
that prefixes name of the executable. This size is then used to allocate a buffer which is where the args are copied into.More details about this issue is documented in the fixed version of
xnu
'skern_sysctl.c
.These bugs are not going to be fixed in Catalina because Apple has discontinued support for the OS. However, Catalina is still technically a supported platform for the latest version of Go, so I went ahead and created a patch in the
x/sys
package that works around thexnu
kernel bug. I'm not sure how to submit it but I am looking for feedback on it.The text was updated successfully, but these errors were encountered: