panic: runtime error: index out of range [7] with length 0
- Lingua principale
- Go
- Stelle
- 8.2k
- Fork
- 614
- Merge medio
- 5g 12h
- PR unite (30g)
- 1
Descrizione
**What is the issue you are having?**
Run for a few seconds and panic
`panic: runtime error: index out of range [7] with length 0`
```
goroutine 60 [running]:
encoding/binary.littleEndian.Uint64(...)
/usr/local/go/src/encoding/binary/binary.go:77
github.com/allegro/bigcache/v2.readTimestampFromEntry(...)
/Users/xx/go/pkg/mod/github.com/allegro/bigcache/v2@v2.2.5/encoding.go:58
github.com/allegro/bigcache/v2.(*cacheShard).onEvict(0xc00010cd80, 0xc0029a02fb, 0x0, 0x9845, 0x60f94108, 0xc000278f00, 0x0)
/Users/xx/go/pkg/mod/github.com/allegro/bigcache/v2@v2.2.5/shard.go:269 +0x85
github.com/allegro/bigcache/v2.(*cacheShard).set(0xc00010cd80, 0xc004e976f8, 0x13, 0x16c4e5b3aad5055c, 0xc004d785d8, 0x6, 0x6, 0x6, 0xc004d785d8)
/Users/xx/go/pkg/mod/github.com/allegro/bigcache/v2@v2.2.5/shard.go:132 +0x31a
github.com/allegro/bigcache/v2.(*BigCache).Set(0xc00009aea0, 0xc004e976f8, 0x13, 0xc004d785d8, 0x6, 0x6, 0x0, 0x0)
/Users/xx/go/pkg/mod/github.com/allegro/bigcache/v2@v2.2.5/bigcache.go:133 +0xac
main.main.func1(0xc00009aea0)
/Users/xx/go/src/x/vod/scheduler/manager/local_cache/example2/main.go:26 +0x7c
created by main.main
/Users/xx/go/src/x/vod/scheduler/manager/local_cache/example2/main.go:24 +0xf8
exit status 2
```
**Minimal, Complete, and Verifiable Example**
```
package main
import (
"fmt"
"math/rand"
"time"
"github.com/allegro/bigcache/v2"
)
func main() {
bc, _ := bigcache.NewBigCache(bigcache.DefaultConfig(time.Second))
for i := 0; i < 100; i++ {
go func() {
for {
_ = bc.Set(randPath(), randValue())
}
}()
}
select {}
}
func randPath() string {
return fmt.Sprintf("%d", rand.Int())
}
func randValue() []byte {
length := rand.Intn(1000)
data := make([]byte, length)
for i := 0; i < length; i++ {
data[i] = byte(rand.Uint32())
}
return data
}
```
**Environment:**
- Version (git sha or release): v2.2.5
- OS: darwin/amd64
- go version: go1.16.6
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.