[ITK-dev] MatrixOffsetTransformBase::GetFixedParameters not ThreadSafe -- regression test?

Williams, Norman K norman-k-williams at uiowa.edu
Fri Oct 24 13:41:31 EDT 2014


If the API says

const bool GetInverse(Self *inverse) const;

If that changes the internal state of the class, isn’t that false advertising?

Actually, I tried just fixing that one problem in MatrixOffsetTransformBase, and it just kicked the problem slightly down the road.

ImageMaskSpatialObject::IsInside also advertises as being a const method; yet it calls SetInternalInverseTransformToWorldToIndexTransform() which is ALSO marked as const, and yet modifies an instance variable.



From: Bradley Lowekamp <blowekamp at mail.nih.gov<mailto:blowekamp at mail.nih.gov>>
Date: Friday, October 24, 2014 at 12:25 PM
To: Mushly McMushmaster <norman-k-williams at uiowa.edu<mailto:norman-k-williams at uiowa.edu>>
Cc: ITK <insight-developers at itk.org<mailto:insight-developers at itk.org>>
Subject: Re: [ITK-dev] MatrixOffsetTransformBase::GetFixedParameters not ThreadSafe -- regression test?

Kent,

Mutable member are evil.

Would it be possible to have the m_Center and the m_FixedArray point to the same block of data?

Brad

On Oct 24, 2014, at 12:59 PM, Williams, Norman K <norman-k-williams at uiowa.edu<mailto:norman-k-williams at uiowa.edu>> wrote:

The problem is worse than I thought.

CompositeTransform::GetFixedParameters() dynamically resizes the FixedParameters array, and then does a bunch of std::copy to copy fixed parameters out of its list of sub-transforms.

The only way to make that thread safe is to use a Mutex lock to guard where it changes the member variable.

From: <Williams>, Mushly McMushmaster <norman-k-williams at uiowa.edu<mailto:norman-k-williams at uiowa.edu>>
Date: Friday, October 24, 2014 at 11:45 AM
To: ITK <insight-developers at itk.org<mailto:insight-developers at itk.org>>
Subject: [ITK-dev] MatrixOffsetTransformBase::GetFixedParameters not ThreadSafe -- regression test?

I was going to address this bug that I just logged:

https://issues.itk.org/jira/browse/ITK-3324

Basically, if GetFixedParameters is called from multiple threads, it introduces a race to resize the internal fixed parameter array.

This was never  a problem before Hans Johnson’s recent patch to propagate fixed parameters int Transform::GetInverse() methods.  He added:

inverse->SetFixedParameters(this->GetFixedParameters());

which makes perfect sense.

I have a decent idea of how to make this better:  Set the fixed parameters’ size in the constructor for MatrixOffsetTransformBase, and set the fixed parameters in SetCenter.  I will review the other instances of GetFixedParameters and GetParameters to see if they’re similarly thread-unsafe.

But how do you write a regression test for this?




________________________________
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.
________________________________


________________________________
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<http://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



________________________________
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/insight-developers/attachments/20141024/37c6e352/attachment.html>


More information about the Insight-developers mailing list