aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2023-03-14 15:34:11 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2023-03-14 15:34:11 +0000
commit7718af9a8fb7705cecbf7a0487a9a58205865227 (patch)
tree14e7c1b7cfb9297681c22ce99d47e56d5c2565c3
parent31e77df946919359cb2b9065612a643714f14d90 (diff)
make TSAN happy (it does not support atomic thread fences)
-rw-r--r--vespalib/src/vespa/vespalib/util/ref_counted.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/vespalib/src/vespa/vespalib/util/ref_counted.cpp b/vespalib/src/vespa/vespalib/util/ref_counted.cpp
index 47bb59bb287..b3ff5e9f43a 100644
--- a/vespalib/src/vespa/vespalib/util/ref_counted.cpp
+++ b/vespalib/src/vespa/vespalib/util/ref_counted.cpp
@@ -20,13 +20,15 @@ enable_ref_counted::internal_subref(uint32_t cnt, [[maybe_unused]] uint32_t rese
{
// release because:
// our changes to the object must be visible to the deleter
- auto prev = _refs.fetch_sub(cnt, std::memory_order_release);
+ //
+ // acquire because:
+ // we need to see all object changes before deleting it
+ auto prev = _refs.fetch_sub(cnt, std::memory_order_acq_rel);
assert(prev >= (reserve + cnt));
assert(_guard == MAGIC);
if (prev == cnt) {
- // acquire because:
- // we need to see all object changes before deleting it
- std::atomic_thread_fence(std::memory_order_acquire);
+ // not using conditional atomic thread fence since thread
+ // sanitizer does not support it.
delete this;
}
}