Skip to content

Slice bound out of range on filterOfflineCPUs #530

@antham

Description

@antham

I got this stack trace

panic: runtime error: slice bounds out of range [4:3]
goroutine 70 [running]:
github.com/prometheus/procfs/sysfs.filterOfflineCPUs(0xc00031e600?, 0xc000243c08)
        /go/pkg/mod/github.com/prometheus/procfs@v0.10.0/sysfs/system_cpu.go:181 +0x23a
github.com/prometheus/procfs/sysfs.FS.SystemCpufreq({{0xbca467?, 0x4?}})
        /go/pkg/mod/github.com/prometheus/procfs@v0.10.0/sysfs/system_cpu.go:209 +0x28b
github.com/prometheus/node_exporter/collector.(*cpuFreqCollector).Update(0x0?, 0x0?)
        /app/collector/cpufreq_linux.go:51 +0x45
github.com/prometheus/node_exporter/collector.execute({0xbcd885, 0x7}, {0xce3840, 0xc000070860}, 0x0?, >
        /app/collector/collector.go:161 +0x9c
github.com/prometheus/node_exporter/collector.NodeCollector.Collect.func1({0xbcd885?, 0x0?}, {0xce3840?>
        /app/collector/collector.go:152 +0x3d
created by github.com/prometheus/node_exporter/collector.NodeCollector.Collect
        /app/collector/collector.go:151 +0xd0

I think what is provided is the following arguments :

filterOfflineCPUs(&[]uint16{2, 3}, &[]string{
	"/sys/devices/system/cpu/cpu0",
	"/sys/devices/system/cpu/cpu1",
	"/sys/devices/system/cpu/cpu2",
	"/sys/devices/system/cpu/cpu3",
})

I guess the problem is occurring because at each loop the slice is reducing, what about introducing another slice to store the result of the filtering ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions