bigcache icon indicating copy to clipboard operation
bigcache copied to clipboard

shard onEvict get an empty oldestEntry.so panic and not unLock

Open s1040735149 opened this issue 3 years ago • 1 comments

What is the issue you are having?

shard onEvict get an empty oldestEntry.so panic and not unLock

What is BigCache doing that it shouldn't? fix panic

Minimal, Complete, and Verifiable Example

runtime error: index out of range [7] with length 0
goroutine 60116345 [running]:
runtime/debug.Stack(0x2153be0, 0x22c8700, 0xc1ec77bf40)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
git.in.zhihu.com/go/utils.SafelyRun.func1(0xc1ea5fdf40)
	/go/pkg/mod/git.in.zhihu.com/go/[email protected]/concurrent.go:20 +0x78
panic(0x22c8700, 0xc1ec77bf40)
	/usr/local/go/src/runtime/panic.go:969 +0x175
encoding/binary.littleEndian.Uint64(...)
	/usr/local/go/src/encoding/binary/binary.go:77
github.com/allegro/bigcache/v3.readTimestampFromEntry(...)
	/go/pkg/mod/github.com/allegro/bigcache/[email protected]/encoding.go:58
github.com/allegro/bigcache/v3.(*cacheShard).onEvict(0xc0ba3fd7a0, 0xc166605820, 0x0, 0xbc7e0, 0x623d7f7d, 0xc1ea5fd730, 0x0)
	/go/pkg/mod/github.com/allegro/bigcache/[email protected]/shard.go:271 +0x85
github.com/allegro/bigcache/v3.(*cacheShard).set(0xc0ba3fd7a0, 0xc1ecdc1ce0, 0x23, 0xd8bc05fe228582f8, 0xc1ecdd9200, 0x29d, 0x2c6, 0x0, 0x0)
	/go/pkg/mod/github.com/allegro/bigcache/[email protected]/shard.go:134 +0x31a
github.com/allegro/bigcache/v3.(*BigCache).Set(0xc000214680, 0xc1ecdc1ce0, 0x23, 0xc1ecdd9200, 0x29d, 0x2c6, 0x0, 0x2105a00)

When asking a question about a problem caused by your code, you will get much better answers if you provide code we can use to reproduce the problem. That code should be...

  • ...Minimal – Use as little code as possible that still produces the same problem
  • ...Complete – Provide all parts needed to reproduce the problem
  • ...Verifiable – Test the code you're about to provide to make sure it reproduces the problem

For more information on how to provide an MCVE, please see the Stack Overflow documentation.

Environment:

  • Version (git sha or release): v3.0.1
  • OS (e.g. from /etc/os-release or winver.exe): linux
  • go version: go 1.15

s1040735149 avatar Mar 25 '22 09:03 s1040735149

@s1040735149 could you try v3.0.2

janisz avatar Mar 25 '22 16:03 janisz