allegro / allegro/bigcache

In some case,the bytes_queue may lead panic

Offen
#300 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Go
Sterne
8.2k
Forks
614
Ø Merge
5 T. 12 Std.
Gemergte PRs (30 T.)
1

Beschreibung

**What is the issue you are having?**
```panic: runtime error: slice bounds out of range [:32898] with capacity 1028

goroutine 1 [running]:
github.com/allegro/bigcache/v3/queue.(*BytesQueue).peek(0xc000107f00, 0x100)
F:/gotest/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/queue/bytes_queue.go:241 +0x130
github.com/allegro/bigcache/v3/queue.(*BytesQueue).Pop(0xc000107f00)
F:/gotest/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/queue/bytes_queue.go:162 +0x26
main.main()
F:/gotest/src/algorithm/switch/switch.go:24 +0x187
```

**Minimal, Complete, and Verifiable Example**

```
package main

import (
"github.com/allegro/bigcache/v3/queue"
)

func FixSizeByteSlice(n int) []byte {
b := make([]byte, n)
for i := range b {
b[i] = 0xff
}
return b
}
func main() {
queue := queue.NewBytesQueue(2*256+2, 655360, true)
queue.Push(FixSizeByteSlice(254))
queue.Push(FixSizeByteSlice(254))
queue.Pop()
queue.Push(FixSizeByteSlice(127))
queue.Push(FixSizeByteSlice(259))
queue.Pop()
queue.Pop()
queue.Pop()
}
```

**Environment:**
- Version (git sha or release):v3.0.1
- OS (e.g. from `/etc/os-release` or winver.exe): windows/amd64
- go version: go1.17

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.