You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If two goroutines enter these functions at the same time, they both can pass the Has() condition in line 1 (as it's not set yet), and then, both execute the Set() operation from line 4 in random order, resulting in a non-deterministic behavior.
A possible solution is to use an approach similar to sync.Map.LoadOrStore() to do operations from lines 1 and 4 together, in an atomic way.
The text was updated successfully, but these errors were encountered:
lklimek
added a commit
to lklimek/tendermint
that referenced
this issue
Sep 28, 2021
Tendermint version master (revision 6be3661)
What happened:
When reviewing the code, I have noticed two potential race condition bugs:
Here's the faulty code:
If two goroutines enter these functions at the same time, they both can pass the
Has()
condition in line 1 (as it's not set yet), and then, both execute the Set() operation from line 4 in random order, resulting in a non-deterministic behavior.A possible solution is to use an approach similar to sync.Map.LoadOrStore() to do operations from lines 1 and 4 together, in an atomic way.
The text was updated successfully, but these errors were encountered: