[Insight-developers] Re: Unsafe code in ObjectMorphologyImage
Filter
Miller, James V (Research)
millerjv at crd . ge . com
Tue, 19 Aug 2003 09:54:47 -0400
It looks like Julien submitted code to address this problem. I looked at
the solution
and I am not convinced this will fix the problem. (It may move it be less
likely.)
I think the problem with the filter is in the Evaluate() methods. The
filter
determines whether a given pixel in the input satisfies the appropriate
conditions and
then calls Evaluate(). The Evaluate() method sets (or unsets) all the
appropriate pixels
in the neighborhood of the output pixel.
Since the Evaluate() methods touches pixels in the neighborhood of the
output pixel,
it may be setting the value for a pixel that it does not own. If a pixel in
the
neighborhood is the responsibility of another thread, you could have
multiple threads
writing to the same pixel.
The Evaluate() methods need to be fixed such that they limit pixel writes to
the outputRegionForThread.
> -----Original Message-----
> From: Stephen R. Aylward [mailto:aylward at unc . edu]
> Sent: Sunday, August 17, 2003 7:09 PM
> To: Lorensen, William E (Research)
> Cc: insight-developers at public . kitware . com
> Subject: [Insight-developers] Re: Unsafe code in
> ObjectMorphologyImageFilter
>
>
>
> Hi,
>
> Julien has been working on this as well, and I took a look at
> it too - I
> am not sure what's up since it even fails on single thread.
> I'll bump
> it up on my to-do list.
>
> Thanks!
>
> Stephen
>
> Lorensen, William E (Research) wrote:
> > Steven
> > I noticed intermittent test failures for the subject
> filter. I tracked the
> > problem down to the ThreadedGenerateData method. There is a
> loop that copies
> > data from the input to the output region. Unfortunately,
> since the region
> > extends beyond the pixels that should be updated in a
> thread, some of this
> > pixels overlay pixels in other threads. As a temporary fix,
> I put a mutex
> > around the loop. The real fix would be to just copy the
> pixels that will be
> > affected in a given thread. Then the mutex can be removed.
> >
> > Forget half of what I just said...
> > After putting in the mutex, I get different failures. I
> think the filter
> > needs to be reviewed further for thread safety. I suspect the
> > IsObjectPixelOnBoundary is messing up. For now, I've set
> the number of
> > threads to 1 for this filter.
> >
> > Bill
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk . org
> http://www . itk . org/mailman/listinfo/insight-developers
>