-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TSAN warnings with AtomicFreeList
I do not think there was an actual error with AtomicFreeList, however TSAN detected a data race when concurrent pop() happened. In that case, there is indeed a race, where we can end-up reading data that is already corrupted by the concurrent pop. However, that situation is corrected by the following CAS. Somehow TSAN didn't see that. The fix is strange and consists in replacing: ``` auto pNext = storage[offset].next; ``` with ``` auto s = storage[offset]; auto pNext = s.next; ``` In this PR we also adjust the memory ordering to be less strong. i.e. we do not need `memory_order_seq_cst`, only the appropriate acquire or release semantic. In addition we also make `Node* next` a non-atomic variable again. It should have been, but was change to placate an older version of TSAN. BUGS=[377369108]
- Loading branch information
1 parent
5dfd285
commit d075a87
Showing
1 changed file
with
20 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters