Skip to content
Snippets Groups Projects
Commit 22350614 authored by scott snyder's avatar scott snyder
Browse files

GeoModelKernel: Fix race in RCBase::unref().

The decrement and test must be done atomically; otherwise we could have
a race.  E.g., suppose a RCBase object has a refcount of 2, and two threads
call unref simultaneously.  The two decrements could both happen before
either of the comparisons, resulting in a double-delete.
parent ff0b07aa
No related branches found
No related tags found
1 merge request!95GeoModelKernel: Fix race in RCBase::unref().
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelKernel/RCBase.h"
......@@ -21,10 +21,7 @@ void RCBase::ref () const
void RCBase::unref () const
{
if (m_count.load()>0) {
m_count--;
if (m_count.load()==0) delete this;
}
if (--m_count == 0) delete this;
}
unsigned int RCBase::refCount () const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment