-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
Go version
go1.20.12 freebsd/386
Output of go env
in your module/workspace:
Not relevant.
What did you do?
- Built the following minimal reproducible Go program targeting FreeBSD, shown here:
FreeBSD: couldn't get uname: cannot allocate memory prometheus/node_exporter#2809 (comment) - Copied the file to a running instances of
pfSense
- Ran it
- Got an
"Cannot allocate memory"
error - Cloned
sys/unix
locally and played around with thesyscall_freebsd.go
file, in particular I commented out sections of theUname
method until I found the section that caused the error. That was this section:
mib = []_C_int{CTL_KERN, KERN_VERSION}
n = unsafe.Sizeof(uname.Version)
if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
return err
}
Upon further digging I found that uname.Version
is set to 256 bytes here:
so then I,
6. Modified the above locally to a larger value, 1024.
7. Rebuilt the test binary with all code from step 5 uncommented.
8. Reran the binary on the pfSense OS,
9. No error.
What did you see happen?
Got "cannot allocate memory"
until I made the Utsname.Version
field larger.
What did you expect to see?
The Uname to be returned.
Apologies if this isn't the correct venue for this report. I'm not a Go developer, nor have I ever worked on FreeBSD or pfSense. I am willing to do what's needed to fix this, but I'm not sure exactly what's "wrong" here. I know the types_freebsd.go
file is auto-generated, but I'm not familiar with the domain to know if:
- pfSense is errantly reporting a KERN_VERSION larger than 256 bytes, or
- the
types_freebsd.go
file needs to be regenerated/modified in some way.
Edit: Fwiw I was doing some reading and it looks like maybe this isn't the first time someone has encountered this issue in FreeBSD?