elastic / go-sysinfo

go-sysinfo is a library for collecting system information.
Apache License 2.0
7 stars 88 forks source link

Panic on macOS Catalina 10.15.7 #173

Open andrewkroh opened 1 year ago

andrewkroh commented 1 year ago

In https://github.com/elastic/go-sysinfo/pull/135 we changed from a custom sysctl implementation to the Go stdlib version. There is a kernel bug^1 in Catalina that causes the stdlib version to return bad data to go-sysinfo. There is issue open in Go to track a possible fix https://github.com/golang/go/issues/60047.

https://github.com/elastic/go-sysinfo/pull/172 adds defensive measures to prevent bad data from causing a panic in go-sysinfo. We probably need another change to revert to the custom sysctl implementation for Catalina (darwin/amd64 version 10.15).

goroutine 1 [running]:
github.com/elastic/go-sysinfo/providers/darwin.kern_procargs(0xc0003df430?, 0xc0001168c0)
github.com/elastic/go-sysinfo@v1.9.0/providers/darwin/process_darwin.go:207 +0x58f
github.com/elastic/go-sysinfo/providers/darwin.(*process).Info(0xc0001168c0)
github.com/elastic/go-sysinfo@v1.9.0/providers/darwin/process_darwin.go:104 +0x1b4
go.elastic.co/apm/v2.currentProcessTitle()
go.elastic.co/apm/v2@v2.0.0/utils_other.go:34 +0x5f
go.elastic.co/apm/v2.getCurrentProcess()
go.elastic.co/apm/v2@v2.0.0/utils.go:83 +0x65
go.elastic.co/apm/v2.init.1()
go.elastic.co/apm/v2@v2.0.0/utils.go:77 +0x2b

https://discuss.elastic.co/t/macos-10-15-7-cannot-execute-filebeat-auditbeat-or-metricbeat/333471

wheelerlaw commented 1 year ago

Once I get my patch submitted, reverting to the custom sysctl implementation shouldn't be necessary.