[ITK-dev] [ITK] Thread-unsafety of transform classes FOLLUWUP
Matt McCormick
matt.mccormick at kitware.com
Tue Oct 28 22:14:49 EDT 2014
Thanks for the further investigations.
I think it should default to zero fixed parameters. Here's a patch:
http://review.source.kitware.com/#/c/17789/
Thanks,
Matt
On Tue, Oct 28, 2014 at 1:41 PM, Bradley Lowekamp
<blowekamp at mail.nih.gov> wrote:
> Perhaps the constructor needs another argument name numberOfFixedParameters,
> which defaults to the prior argument?
>
> Brad
>
> On Oct 28, 2014, at 1:21 PM, Williams, Norman K
> <norman-k-williams at uiowa.edu> wrote:
>
> 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.
> ________________________________
> _______________________________________________
> 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
>
>
>
> _______________________________________________
> 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
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
More information about the Insight-developers
mailing list