jaypipes / ghw

Go HardWare discovery/inspection library
Apache License 2.0
1.62k stars 174 forks source link

Panic when collecting host information #326

Closed IvanRibakov closed 1 year ago

IvanRibakov commented 2 years ago

During the execution of this line of code in a VirtualBox VM running CentOS 8, go panicked with the following message:

host, err := ghw.Host(ghw.WithDisableWarnings())
panic: runtime error: slice bounds out of range [6:3]

goroutine 16 [running]:
github.com/jaypipes/pcidb.parseDBFile(0xc0008ca240, 0xc0005457a8, 0x3, 0xc000000000)
        /Volumes/data/work/zaleos/git/softin-shared/licensing/vendor/github.com/jaypipes/pcidb/parse.go:72 +0x17cc
github.com/jaypipes/pcidb.(*PCIDB).load(0xc0008ca240, 0xc000309ce0, 0x0, 0x0)
        /Volumes/data/work/zaleos/git/softin-shared/licensing/vendor/github.com/jaypipes/pcidb/discover.go:61 +0x213
github.com/jaypipes/pcidb.New(0xc000545960, 0x1, 0x1, 0xd, 0xc0008ca228, 0x0)
        /Volumes/data/work/zaleos/git/softin-shared/licensing/vendor/github.com/jaypipes/pcidb/main.go:192 +0x8a
github.com/jaypipes/ghw/pkg/pci.(*Info).load(0xc00041dd00, 0x1, 0x1)
        /Volumes/data/work/zaleos/git/softin-shared/licensing/vendor/github.com/jaypipes/ghw/pkg/pci/pci_linux.go:43 +0xec
github.com/jaypipes/ghw/pkg/pci.New.func1(0xc0002b5680, 0x0)
        /Volumes/data/work/zaleos/git/softin-shared/licensing/vendor/github.com/jaypipes/ghw/pkg/pci/pci.go:170 +0x1b3
github.com/jaypipes/ghw/pkg/context.(*Context).Do(0xc0002b5680, 0xc000545ad8, 0x0, 0x0)
        /Volumes/data/work/zaleos/git/softin-shared/licensing/vendor/github.com/jaypipes/ghw/pkg/context/context.go:125 +0x90
github.com/jaypipes/ghw/pkg/pci.New(0xc000545bf8, 0x1, 0x1, 0xc0002b5500, 0x0, 0x0)
        /Volumes/data/work/zaleos/git/softin-shared/licensing/vendor/github.com/jaypipes/ghw/pkg/pci/pci.go:177 +0x105
github.com/jaypipes/ghw.Host(0xc000545bf8, 0x1, 0x1, 0x1, 0x1, 0xc0000b6030)
        /Volumes/data/work/zaleos/git/softin-shared/licensing/vendor/github.com/jaypipes/ghw/host.go:90 +0x3a5
... (non-ghw code)

Go script was executed with root privileges.

Any insights into what might be causing this?

ffromani commented 1 year ago

Hi @IvanRibakov . I believe ghw.WithDisableWarnings() is not a contributing factor. Could you please doublecheck you get the same error without that value? The real error seems to be in the pci database parsing. If so we would probably need to file an issue in github.com/jaypipes/pcidb. But even before that: do you perhaps have a minimal reproducer we can use to better investigate the problem?.

For example, does this happen on a vanilla centos 8 image? what is the minimal centos 8 image which reproduces this behavior?

jaypipes commented 1 year ago

@IvanRibakov any response on this one? If not, I'd like to close it out as not reproducible.

IvanRibakov commented 1 year ago

I'll give it another go next week. Is there any additional information that I could gather from the VM that could help with diagnosing the issue?

jaypipes commented 1 year ago

@IvanRibakov you can use the ghw-snapshot utility. To install, do:

go install -u github.com/jaypipes/ghw/cmd/ghw-snapshot

and then simply run it from a shell inside your VM.

IvanRibakov commented 1 year ago

Closing as I'm unable to reproduce this.