aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahooinc.com>2023-03-14 18:39:00 +0100
committerGitHub <noreply@github.com>2023-03-14 18:39:00 +0100
commit2f8683df80c88fc86cb8e84026b64a399e446cfb (patch)
treee06bb994ba7f546517abb711a549b41cadafb5e3
parentd8ce9e0e76d317c32b703a899c78e78720be708d (diff)
parent7718af9a8fb7705cecbf7a0487a9a58205865227 (diff)
Merge pull request #26441 from vespa-engine/havardpe/avoid-atomic-thread-fence
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;
}
}