Open pdddddddddddd opened 1 month ago
Thank you for reporting this @pdddddddddddd. I think this method should not perform any modifications at all. So we should probably change Items()
's logic to something like what Keys()
is using (i.e., we should not use the get()
method internally).
Hi all, As per the readme, this package is thread safe, but I've noticed a data race in
Items()
.A simple example:
Output:
From a quick skim, this appears to be due to the fact that
.Items()
holds anRLock()
on the mutex, but when.Items()
callsget
, it doesc.items.lru.MoveToFront(elem)
which mutates the underlying list, as hinted at by this comment onget
:I suppose a simple fix would be to change
.Items()
to this instead?