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

Panic when using expirable cache #181

Open
kalafut opened this issue Sep 4, 2024 · 0 comments
Open

Panic when using expirable cache #181

kalafut opened this issue Sep 4, 2024 · 0 comments

Comments

@kalafut
Copy link

kalafut commented Sep 4, 2024

When testing with an expirable.LRU, I've seen the crash below. I was using size=100 and expiration=1 second, and the access pattern was all around a single key. The test had a couple concurrent reads per second, and a write of the same key any time there was a cache miss. I'd reliably hit this panic after a few seconds.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x102c011b8]

goroutine 21 [running]:
github.com/hashicorp/golang-lru/v2/internal.(*LruList[...]).Remove(...)
	/Users/kalafut/go/pkg/mod/github.com/hashicorp/golang-lru/[email protected]/internal/list.go:97
github.com/hashicorp/golang-lru/v2/expirable.(*LRU[...]).removeElement(0x140001c6ff0?, 0x1400020aea8?)
	/Users/kalafut/go/pkg/mod/github.com/hashicorp/golang-lru/[email protected]/expirable/expirable_lru.go:298 +0x28
github.com/hashicorp/golang-lru/v2/expirable.(*LRU[...]).deleteExpired(0x102fb2c20)
	/Users/kalafut/go/pkg/mod/github.com/hashicorp/golang-lru/[email protected]/expirable/expirable_lru.go:319 +0x20c
github.com/hashicorp/golang-lru/v2/expirable.NewLRU[...].func1()
	/Users/kalafut/go/pkg/mod/github.com/hashicorp/golang-lru/[email protected]/expirable/expirable_lru.go:90 +0xa0
created by github.com/hashicorp/golang-lru/v2/expirable.NewLRU[...] in goroutine 1
	/Users/kalafut/go/pkg/mod/github.com/hashicorp/golang-lru/[email protected]/expirable/expirable_lru.go:82 +0x2b8
exit status 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant