allegro / allegro/bigcache

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

Đang mở
#290 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug hacktoberfest
Ngôn ngữ chính
Go
Star
8.2k
Fork
614
Merge trung bình
5 ngày 12 giờ
Pull request đã merge (30 ngày)
1

Mô tả

```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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.