go-graphite / go-carbon

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

fix: panic on slice bounds out of range when preparing data stream #599

Closed dowster closed 4 months ago

dowster commented 4 months ago

We've been seeing fatals from go-carbon when queries pull back more than the max metrics limit. Unsure which of these values is the one being read but it seemed like guarding all of them would be the best approach.

fatal log:

2024-07-09 14:58:57.474 panic: runtime error: slice bounds out of range [:40000] with capacity 0
2024-07-09 14:58:57.474 
2024-07-09 14:58:57.474 goroutine 4140 [running]:
2024-07-09 14:58:57.474 github.com/go-graphite/go-carbon/carbonserver.(*CarbonserverListener).prepareDataStream(0xc00014e000, {0xf71cf8, 0xc03ca6c780}, 0x2, 0xc03ca3dcb0?, 0xc03ca3dec0?, 0xc03ca7c600)
2024-07-09 14:58:57.474     /usr/local/src/go-carbon/carbonserver/render.go:425 +0xf4d
2024-07-09 14:58:57.474 github.com/go-graphite/go-carbon/carbonserver.(*CarbonserverListener).prepareDataProto.func1()
2024-07-09 14:58:57.474     /usr/local/src/go-carbon/carbonserver/render.go:495 +0xb3
2024-07-09 14:58:57.474 created by github.com/go-graphite/go-carbon/carbonserver.(*CarbonserverListener).prepareDataProto
2024-07-09 14:58:57.474     /usr/local/src/go-carbon/carbonserver/render.go:493 +0x4d5
deniszh commented 4 months ago

LGTM, merging. Thanks a lot!