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.
Dieser Commit ist enthalten in:
Ioannis Assiouras
2025-10-20 17:15:56 +01:00
committet von GitHub
Ursprung ad3cb435ee
Commit 30a14a8a05
+1 -1
Datei anzeigen
@@ -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