Open pando85 opened 1 year ago
Same here
I suppose this comes from here: https://github.com/prometheus/node_exporter/blob/7dd2f0dc4f632f7778be134ace0e7c8ecdfe279a/collector/uname_bsd.go#L28
Can create a minimal program using unix.Uname() to reproduce this? Might be a golang issue. Also, have you tried the current master version?
Happening also on latest pfSense OSS v2.7.2 (based on FreeBSD 14)
Please anyone try to reproduce this by running the following:
package main
import (
"log"
"golang.org/x/sys/unix"
)
func main() {
var utsname unix.Utsname
if err := unix.Uname(&utsname); err != nil {
log.Fatal(err)
}
log.Printf("%s", utsname)
}
Please anyone try to reproduce this by running the following:
package main import ( "log" "golang.org/x/sys/unix" ) func main() { var utsname unix.Utsname if err := unix.Uname(&utsname); err != nil { log.Fatal(err) } log.Printf("%s", utsname) }
Yes, this reproduces the exact same input described above:
2024/02/07 17:11:22 cannot allocate memory
I have tested, by building the above with the entirety of https://cs.opensource.google/go/x/sys/+/master:unix/syscall_freebsd.go;l=169-213;bpv=0?q=Uname&ss=go%2Fx%2Fsys commented out and progressively uncommenting line by line and running each executable as I go along and have determined that this line chunk:
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
}
to be the cause. Your minimal repro code snippet works if I leave everything but this section commented out, and continues to fail to alloc if I leave this chunk in. I have never written Go, so I'm not sure if I'll be able to fix this but wanted to drop this here in case anyone else lands here.
Edit
https://man.freebsd.org/cgi/man.cgi?sysctl(3)
This is because the Version
field of Utsname
is too small. It's 256 bytes above, but in pfsense this string is larger.
@seeplusplus Great job debugging and thanks for opening the golang issue!
@seeplusplus Great job debugging and thanks for opening the golang issue!
The fix for the issue in sys/unix was merged to master this morning. It seems like there are some other issues in this repo preventing successful builds on FreeBSD though. I started taking a look a those over the weekend.
Host operating system: output of
uname -a
node_exporter version: output of
node_exporter --version
node_exporter command line flags
node_exporter log output
Are you running node_exporter in Docker?
No
What did you do that produced an error?
Run
node_exporter
.What did you expect to see?
node_uname_info
metric.What did you see instead?