Skip to content

Commit

Permalink
BUG: fixed simultaneous read/write access of same ivar by different t…
Browse files Browse the repository at this point in the history
…hreads

Made the ivar atomic, so at least the simultaneous access is well-defined.

Found by TSan.  A great many tests were failing because of this.
  • Loading branch information
seanm authored and hjmjohnson committed Jan 18, 2022
1 parent 976baf8 commit 142e254
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Modules/Core/Common/include/itkMultiThreaderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "itkImageRegion.h"
#include "itkImageIORegion.h"
#include "itkSingletonMacro.h"
#include <atomic>
#include <functional>
#include <thread>
#include "itkProgressReporter.h"
Expand Down Expand Up @@ -484,7 +485,7 @@ ITK_GCC_PRAGMA_DIAG_POP()
/** Only used to synchronize the global variable across static libraries.*/
itkGetGlobalDeclarationMacro(MultiThreaderBaseGlobals, PimplGlobals);

bool m_UpdateProgress{ true };
std::atomic<bool> m_UpdateProgress{ true };

static MultiThreaderBaseGlobals * m_PimplGlobals;
/** Friends of Multithreader.
Expand Down

0 comments on commit 142e254

Please sign in to comment.