Skip to content

Commit 915b8e4

Browse files
seanmhjmjohnson
authored andcommitted
BUG: fixed threading bug, don't use vector<bool> from multiple threads
vector<bool> is not thread safe due to the possibility of multiple bits being packed together in the same memory location. Found by TSan.
1 parent 1639cab commit 915b8e4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ class ITK_TEMPLATE_EXPORT QuasiNewtonOptimizerv4Template
151151
/** The Hessian with local support */
152152
HessianArrayType m_HessianArray;
153153

154-
/** Valid flag for the Quasi-Newton steps */
155-
std::vector<bool> m_NewtonStepValidFlags;
154+
/** Valid flag for the Quasi-Newton steps.
155+
* NB: although semantically boolean, vector<bool> is not thread safe due to the possibility of multiple bits being
156+
* packed together in the same memory location.
157+
*/
158+
std::vector<uint8_t> m_NewtonStepValidFlags;
156159

157160
/** Estimate a Newton step */
158161
virtual void

0 commit comments

Comments
 (0)