[ITK] [ITK-dev] Thread-unsafety of transform classes FOLLUWUP
Williams, Norman K
norman-k-williams at uiowa.edu
Tue Oct 28 13:21:31 EDT 2014
This is mostly for Bradley Lowenkamp and Matt McCormick, but at some point the wider developer community will be affected and input solicited.
The MatrixOffsetTransformBase has 3 values in its FixedParameters, which is the values of the center of rotation.
There was a mystery as to why MatrixOffsetTransformBase starts out with 12 fixed parameters, when it only really has 3.
The reason is in the constructor for Transform, which initializes the FixedParameters to have the same number of values as the Parameters.
This is a design flaw; it represents the Anti-Pattern “Initialize a member/variable to a default that is almost always wrong.”
This leads to most Transform classes resizing the FixedParameters when GetFixedParameters is called, and assigning their value based on the actual fixed parameters for that Transform class.
This is thread-unsafe, since resizing m_FixedParameters involves a free/allocate pair.
template <typename TScalar,
unsigned int NInputDimensions,
unsigned int NOutputDimensions>
Transform<TScalar, NInputDimensions, NOutputDimensions>
::Transform(NumberOfParametersType numberOfParameters) :
m_Parameters(numberOfParameters),
m_FixedParameters(numberOfParameters)
#ifdef ITKV3_COMPATIBILITY
, m_SharedLocalJacobian(NOutputDimensions, numberOfParameters)
#endif
{
}
________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20141028/b49d63d8/attachment-0001.html>
-------------- next part --------------
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-developers
More information about the Community
mailing list