[Insight-developers] ImageRandomNonRepeatingConstIteratorWithIndex segfault
David Doria
daviddoria at gmail.com
Sun Feb 27 09:48:00 EST 2011
On Sat, Feb 26, 2011 at 3:36 PM, David Doria <daviddoria at gmail.com> wrote:
> If I create this iterator with:
> itk::ImageRandomNonRepeatingConstIteratorWithIndex<ImageType>
> imageIterator(image, image->GetLargestPossibleRegion());
>
> everything works fine. However, if I do this:
>
> itk::ImageRandomNonRepeatingConstIteratorWithIndex<ImageType>
> imageIterator;
> imageIterator =
> itk::ImageRandomNonRepeatingConstIteratorWithIndex<ImageType>(image,
> image->GetLargestPossibleRegion());
>
> it segfaults on the GoToBegin() call.
>
> The crash is at this line of UpdatePosition():
>
> PositionValueType position = ( *( this->m_Permutation )
> )[m_NumberOfSamplesDone % m_NumberOfSamplesRequested];
>
> m_Permutation is valid (it was set when the (image, region) constructor was
> called), but m_Permutation->m_Permutation is NULL. It is valid when I create
> the iterator with the first version (above). The default constructor just
> sets everything to NULL, so I don't see any reason why calling the (image,
> region) constructor after the default constructor wouldn't work.
>
> Any thoughts?
>
> David
>
The problem was that there was no assignment operator. I implemented one
here:
http://review.source.kitware.com/#change,1081
<http://review.source.kitware.com/#change,1081>and it fixed the problem.
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110227/f12a7217/attachment.htm>
More information about the Insight-developers
mailing list