-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in createTimeWithContext when run on FreeBSD arm64 #1636
Comments
I can pass
|
I'm just testing with the artifact freebsd_armv7.tar.gz provided influxdata/telegraf#15272 . Hoping that @powersj could tell you more about the build. I'm not a go user, how do I run I tried:
|
Can you run In the original issue, I had the reporter use the following code. You can see his response for the output. |
root@brain:~/gopsutil # go test -v -run Test_Process_CreateTime ./process/...
go: downloading golang.org/x/sys v0.20.0
go: downloading github.com/stretchr/testify v1.9.0
=== RUN Test_Process_CreateTime
--- PASS: Test_Process_CreateTime (0.00s)
PASS
ok github.com/shirou/gopsutil/v3/process 0.016s |
Thank you for the information. This means that, at least in the test environment, the |
Well gopsutil should not panic :) In the original issue, I had sdalu, first get a process using the scripts own PID:
This returned nothing, yet the test does. Can you run the following go code: go.mod: module test-process
go 1.22
require github.com/shirou/gopsutil/v3 v3.24.4
require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/sys v0.20.0 // indirect
) main.go: package main
import (
"fmt"
"os"
"github.com/shirou/gopsutil/v3/process"
)
func main() {
currentPid := os.Getpid()
myself, err := process.NewProcess(int32(currentPid))
if err != nil {
panic(err)
}
fmt.Println(myself.Name())
fmt.Println(myself.String())
fmt.Println(myself.NumThreads())
fmt.Println(myself.RlimitUsage(true))
fmt.Println(myself.Status())
time, err := myself.CreateTime()
if err != nil {
panic(err)
}
fmt.Println(time)
} And either run this directly via go run . or build it go build . and run the test-process binary. |
I'm using go 1.21
|
Well that is not what I was expecting. Just to confirm, this was run on your FreeBSD system that was showing the issue with Telegraf? |
Yes. I re-run the telegraf artifact, just in case. It's crashing with the same panic. Should I try to build it instead of runing the artifact ? |
@sdalu I have put up influxdata/telegraf#15355 which will hopefully print out what the result of Thanks! |
@powersj Here is the output:
|
Thanks for trying that out!
@shirou any reason why the kinfoproc would be nil? Does that mean gopsutil failed to parse the information but didn't generate an error? That print statement is from my own fork, printing out the k value before we attempt to create time with context: |
I read the code and it doesn't seem like |
As before, can you grab the telegraf artifacts in few minutes from this post at: influxdata/telegraf#15397 @shirou - thanks for looking into this! |
@powersj here is the result (looks the same):
I downloaded: |
The parseKinfoProc function returns a struct instance, not a pointer. Therefore, I agree that it should be impossible for a pointer to this value to be nil. However, it is actually happening, so I am very confused. |
@shirou - can that be changed? Otherwise you would need to check if any of the pointer fields are nil? |
Describe the bug
When running telegraph 1.31.0~553d972c, with gopsutil v3.24.4, it crash in the createTimeWithContext.
Issue initially reported: influxdata/telegraf#13933
Environment (please complete the following information):
FreBSD:
14.0-RELEASE-p4
14.0-RELEASE-p4
14.0-RELEASE-p4
FreeBSD brain.home.sdalu.com 14.0-RELEASE-p4 FreeBSD 14.0-RELEASE-p4 #0 releng/14.0-n265400-4edf3b80733e: Wed Jan 17 19:32:19 CET 2024 [email protected]:/usr/obj/usr/src/arm64.aarch64/sys/BROADCOM arm64
The text was updated successfully, but these errors were encountered: