allegro / allegro/bigcache

Iterator readEntry crashes

オープン
#222 コメント 10 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Go
スター
8.2k
フォーク
614
平均マージ
5日 12時間
マージ済み PR(30日)
1

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。