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:
committet von
GitHub
Ursprung
ad3cb435ee
Commit
30a14a8a05
@@ -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
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren