go-graphite / go-carbon

Golang implementation of Graphite/Carbon server with classic architecture: Agent -> Cache -> Persister
MIT License
801 stars 126 forks source link

[BUG] panic: runtime error: slice bounds out of range #552

Open flucrezia opened 1 year ago

flucrezia commented 1 year ago

Describe the bug Panic when max-metrics-rendered is less than number of files in a single render call. To reproduce:

Logs **panic: runtime error: slice bounds out of range [:1000] with capacity 0

goroutine 7080414 [running]: github.com/go-graphite/go-carbon/carbonserver.(CarbonserverListener).prepareDataStream(0xc000208380, {0xf70c78, 0xc085090cf0}, 0x3, 0xc013e2e228?, 0x0?, 0xc008fcb740) /usr/local/src/go-carbon/carbonserver/render.go:423 +0xf45 github.com/go-graphite/go-carbon/carbonserver.(CarbonserverListener).prepareDataProto.func1() /usr/local/src/go-carbon/carbonserver/render.go:493 +0xb3 created by github.com/go-graphite/go-carbon/carbonserver.(*CarbonserverListener).prepareDataProto /usr/local/src/go-carbon/carbonserver/render.go:491 +0x4d5**

Go-carbon Configuration: max-metrics-rendered = 1000

Commenting the above line to use the default value avoids the runtime error.