allegro / allegro/bigcache

panic: runtime error: index out of range [7] with length 0

Ouverte
#290 4 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug hacktoberfest
Langage dominant
Go
Étoiles
8.2k
Forks
614
Merge moyen
5 j 12 h
PR mergées (30 j)
1

Description

```golang

panic: runtime error: index out of range [7] with length 0

goroutine 1417 [running]:
encoding/binary.littleEndian.Uint64(...)
/usr/local/go/src/encoding/binary/binary.go:77
github.com/allegro/bigcache/v3.readTimestampFromEntry(...)
.../pkg/mod/github.com/allegro/bigcache/v3@v3.0.0-20210909062657-c2b72fe951a1/encoding.go:58
github.com/allegro/bigcache/v3.(*cacheShard).onEvict(0xc0087c27e0, 0xc045dda415, 0x0, 0xafeb, 0x614ad1a7, 0xc0008a3e58, 0x0)
.../pkg/mod/github.com/allegro/bigcache/v3@v3.0.0-20210909062657-c2b72fe951a1/shard.go:271 +0x85
github.com/allegro/bigcache/v3.(*cacheShard).cleanUp(0xc0087c27e0, 0x614ad1a7)
.../pkg/mod/github.com/allegro/bigcache/v3@v3.0.0-20210909062657-c2b72fe951a1/shard.go:284 +0xb6
github.com/allegro/bigcache/v3.(*BigCache).cleanUp(0xc001b1e410, 0x614ad1a7)
.../pkg/mod/github.com/allegro/bigcache/v3@v3.0.0-20210909062657-c2b72fe951a1/bigcache.go:215 +0x53
github.com/allegro/bigcache/v3.newBigCache.func1(0x400, 0x34630b8a000, 0xdf8475800, 0x2800, 0x12, 0x101, 0x1142680, 0x196d898, 0x600, 0x0, ...)
.../pkg/mod/github.com/allegro/bigcache/v3@v3.0.0-20210909062657-c2b72fe951a1/bigcache.go:92 +0x9b
created by github.com/allegro/bigcache/v3.newBigCache
.../pkg/mod/github.com/allegro/bigcache/v3@v3.0.0-20210909062657-c2b72fe951a1/bigcache.go:86 +0x4a5

```

i found this panic caused by these codes :

bytes_queue.go#allocateAdditionalMemory

```golang

if leftMarginIndex != q.rightMargin {
copy(q.array, oldArray[:q.rightMargin])

if q.tail <= q.head {
if q.tail != q.head {
headerEntrySize := getUvarintSize(uint32(q.head - q.tail))
emptyBlobLen := q.head - q.tail - headerEntrySize
q.push(make([]byte, emptyBlobLen), emptyBlobLen)
}

q.head = leftMarginIndex
q.tail = q.rightMargin
}
}

```
here are one issue:

1. q.push(make([]byte, emptyBlobLen), emptyBlobLen) value is not wrappedEntry bytes ,this cause , cleanUp method and pop head to recycle these spaces , and decodes ,these causes decoding panic. emptyBlobLen must be larger than minimumHeaderSize

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.