Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem still exists in version 3.0.1,panic: runtime error: index out of range [7] with length 0 #305

Open
784909593 opened this issue Jan 12, 2022 · 8 comments
Labels

Comments

@784909593
Copy link

In theory, this issues is fix in v3.0.1, but I still met

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

runtime/debug.Stack()
        /home/xx/Apps/go/src/runtime/debug/stack.go:24 +0x65
golang.org/x/sync/singleflight.newPanicError({0x120c9a0, 0xc26e4c02d0})
        /home/xx/.go/pkg/mod/golang.org/x/sync@v0.0.0-20201207232520-09787c993a3a/singleflight/singleflight.go:35 +0x2c
golang.org/x/sync/singleflight.(*Group).doCall.func2.1()
        /home/xx/.go/pkg/mod/golang.org/x/sync@v0.0.0-20201207232520-09787c993a3a/singleflight/singleflight.go:188 +0x3b
panic({0x120c9a0, 0xc26e4c02d0})
        /home/xx/Apps/go/src/runtime/panic.go:1038 +0x215
encoding/binary.littleEndian.Uint64(...)
        /home/xx/Apps/go/src/encoding/binary/binary.go:77
github.com/allegro/bigcache/v3.readTimestampFromEntry(...)
        /home/xx/.go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/encoding.go:58
github.com/allegro/bigcache/v3.(*cacheShard).onEvict(0xc0edece368, {0xc377a92025, 0x50beccc039db3211, 0x0}, 0x0, 0x0)
        /home/xx/.go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/shard.go:271 +0x65
github.com/allegro/bigcache/v3.(*cacheShard).set(0xc0edece360, {0xc2326b0550, 0x4d}, 0x0, {0xc0dc931800, 0x7e, 0x400})
        /home/xx/.go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/shard.go:134 +0x1a5
github.com/xx/bigcache/v3.(*BigCache).Set(0xc0001b61a0, {0xc2326b0550, 0x4d}, {0xc0dc931800, 0x7e, 0x400})
        /home/xx/.go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/bigcache.go:133 +0x8d
git.yfcloud.com/supercdn/supercdn_group/scheduler/minerpool/src/cache.(*customCache).Set(...)
        /home/xx/Codes/go/scdn/scheduler/minerpool/src/cache/custom_cache.go:59

@janisz
I had the same problem with the same version, but it's hard to find a stable reproducible case. This problem will cause bigcache deadlock, and the hidden danger is very large.

Originally posted by @784909593 in #283 (comment)

@janisz janisz added the bug label Jan 18, 2022
@janisz
Copy link
Collaborator

janisz commented Jan 18, 2022

Thanks for reporting this. Indeed without minimal reproducible example it's super hard to prepare a fix and ensure it was really fixed.

@JamesSunXX
Copy link

panic(0x175a640, 0xc01e3d3b20)
/var/jenkins_home/go/go1.15.6/src/runtime/panic.go:975 +0x47a
encoding/binary.littleEndian.Uint64(...)
/var/jenkins_home/go/go1.15.6/src/encoding/binary/binary.go:77
github.com/allegro/bigcache/v3.readTimestampFromEntry(...)
/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/encoding.go:58
github.com/allegro/bigcache/v3.(*cacheShard).onEvict(0xc00037b8c0, 0xc023bc0f6a, 0x0, 0x57dbe, 0x6204692b, 0xc01e6b06a8, 0x0)
/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/shard.go:271 +0x85
github.com/allegro/bigcache/v3.(*cacheShard).set(0xc00037b8c0, 0xc01e3ed930, 0xd, 0xc7022ec1611f8c45, 0xc01de4f400, 0x3ce, 0x400, 0x3ce, 0xc01de4f400)
/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/shard.go:134 +0x31a
github.com/allegro/bigcache/v3.(*BigCache).Set(0xc0000a6dd0, 0xc01e3ed930, 0xd, 0xc01de4f400, 0x3ce, 0x400, 0x0, 0x0)
/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/bigcache.go:133 +0xac

go version 1.15, same panic stack

@JamesSunXX
Copy link

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

goroutine 57 [running]:
encoding/binary.littleEndian.Uint64(...)
	/var/jenkins_home/go/go1.15.6/src/encoding/binary/binary.go:77
github.com/allegro/bigcache/v3.readTimestampFromEntry(...)
	/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/encoding.go:58
github.com/allegro/bigcache/v3.(*cacheShard).onEvict(0xc00777eb40, 0xc025622171, 0x0, 0x6cbb7, 0x62036d13, 0xc000056e40, 0x0)
	/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/shard.go:271 +0x85
github.com/allegro/bigcache/v3.(*cacheShard).cleanUp(0xc00777eb40, 0x62036d13)
	/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/shard.go:284 +0xb6
github.com/allegro/bigcache/v3.(*BigCache).cleanUp(0xc0004e00d0, 0x62036d13)
	/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/bigcache.go:215 +0x53
github.com/allegro/bigcache/v3.newBigCache.func1(0x400, 0x1a3185c5000, 0x8bb2c97000, 0x927c0, 0x1f4, 0x0, 0x1b17260, 0x2823c78, 0x1000, 0x0, ...)
	/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/bigcache.go:92 +0x9b
created by github.com/allegro/bigcache/v3.newBigCache
	/root/go/pkg/mod/github.com/allegro/bigcache/v3@v3.0.1/bigcache.go:86 +0x4a5

another panic stack

@temuera
Copy link

temuera commented Feb 11, 2022

1.17.6 same prob.

2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 2340000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 532.4µs; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 46.7µs; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 598.7µs; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 17.2µs; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 550.1µs; Capacity: 1170000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:09 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:10 Allocated new queue in 0s; Capacity: 585000
2022/02/11 16:13:10 Allocated new queue in 0s; Capacity: 585000
panic: runtime error: index out of range [7] with length 0

goroutine 224 [running]:
encoding/binary.littleEndian.Uint64(...)
c:/go/src/encoding/binary/binary.go:77

@Fabianexe
Copy link
Contributor

I am not sure, but it looks like #266 is missing in 3.0.1
This could be a reason for the panic

@janisz
Copy link
Collaborator

janisz commented Feb 14, 2022

@784909593
Copy link
Author

@JamesSunXX @784909593 Could you try https://github.com/allegro/bigcache/releases/tag/v3.0.2

After reading this issue #300, I temporarily used the master 77bbe version, and this problem did not happen again

@blackbeans
Copy link
Contributor

blackbeans commented Aug 19, 2022

This issue is the same as #290
is it resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants