sync: unlock of unlocked mutex
Closed this issue · 2 comments
liangsqrt commented
The problem arises when I use the store method. I was simply using the load and store methods. it works well at first, but as the amount of data in the map gets larger, the probability of an error becomes higher.
func (m *MapOf[K, V]) waitForResize() {
m.resizeMu.Lock()
for m.resizeInProgress() {
m.resizeCond.Wait()
}
m.resizeMu.Unlock()
}
located in the waitForResize process, i found xsync.MapOf unlocks its resizeCond.L when the state of the L has been -1 m.
puzpuzpuz commented
You're likely copying the map via value (xsync.MapOf[int, int]
) instead of pointer (*xsync.MapOf[int, int]
) somewhere in your code. Map
/MapOf
has to be created with one of the New*Map*
functions and then stored as a pointer. Could you check that?
liangsqrt commented
Your insights are spot on. Thanks a lot. It was indeed my mistake to use pointers and objects incorrectly in the code.