Skip to content

Commit 5320def

Browse files
committed
Tweak the memory ordering in ConcurrentMap
Make sure the memory synchronization ordering on success is strictly stronger than the memory ordering of failure. This addresses a race reported by TSan when having both Swift tests and the runtime TSanified.
1 parent f49e6ad commit 5320def

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/swift/Runtime/Concurrent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ template <class EntryTy> class ConcurrentMap {
297297

298298
// Try to set the edge to the new node.
299299
if (std::atomic_compare_exchange_strong_explicit(edge, &node, newNode,
300-
std::memory_order_release,
300+
std::memory_order_acq_rel,
301301
std::memory_order_acquire)) {
302302
// If that succeeded, cache and report that we created a new node.
303303
LastSearch.store(newNode, std::memory_order_release);

0 commit comments

Comments
 (0)