SWDEV-559166 - Fix potential data race in ReferenceCountedObject::release() (#1388)

Use fetch_sub(std::memory_order_acq_rel) on release
so the destroying thread acquires prior writes.
Esse commit está contido em:
Ioannis Assiouras authored and GitHub committed 2025-10-20 17:15:56 +01:00
1 pai ad3cb435ee
commit 30a14a8a05
1 file changed
+1 -1
+1 -1
Ver Arquivo
@@ -134,7 +134,7 @@ uint ReferenceCountedObject::retain() {
}
uint ReferenceCountedObject::release() {
uint newCount = referenceCount_.fetch_sub(1, std::memory_order_relaxed) - 1;
uint newCount = referenceCount_.fetch_sub(1, std::memory_order_acq_rel) - 1;
if (newCount == 0) {
if (terminate()) {
// The destructor should be called with a count==1 for the last thread