allegro / allegro/bigcache

Iterator readEntry crashes

Abierto
#222 10 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Go
Estrellas
8.2k
Forks
614
Merge medio
5 d 12 h
PR fusionados (30 d)
1

Descripción

**What is the issue you are having?**
Sometimes when using EntryInfoIterator to read all entries from the cache, the readEntry() call crashes with the following stack trace:

```
runtime error: makeslice: len out of range
panic(0x1fabc00, 0x27ff350)
/usr/local/go/src/runtime/panic.go:975 +0x3e3
github.com/allegro/bigcache.readEntry(...)
/usr/local/Code/src/github.com/allegro/bigcache/encoding.go:36
github.com/allegro/bigcache.(*EntryInfoIterator).Value(0xc10fd94a50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Code/src/github.com/allegro/bigcache/iterator.go:120 +0x305
```

We only recently updated from an old version of bigcache. This error seems to indicate the object being read is somehow larger than the maximum slice length, which should not be possible given we marshal the structs to bytes using `protobuf`'s `Marshal()` method:

```
func (m *CacheEntry) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
```
We are running on a 64bit system and we limit the size of all entries to ~1MB anyhow.

**What is BigCache doing that it shouldn't?**

It is not clear reading the code, but it seems related to how readEntry() determines length, perhaps some kind of overflow issue.

**Environment:**
- Version (git sha or release): v2.2.1
- OS (e.g. from `/etc/os-release` or winver.exe): ubuntu 16.04
- go version: 1.14.2

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.