Skip to content

Commit

Permalink
BUG: Address race condition with threaded copying input to output
Browse files Browse the repository at this point in the history
Move copying input to output to before threaded methods, to ensure
the operation has been completed before modifications.
  • Loading branch information
blowekamp committed Nov 25, 2024
1 parent b1b9bfd commit 08bc946
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,11 @@ ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::BeforeThreadedG
{
this->GetOutput()->FillBuffer(0);
}
}

template <typename TInputImage, typename TOutputImage, typename TKernel>
void
ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::DynamicThreadedGenerateData(
const OutputImageRegionType & outputRegionForThread)
{
ImageRegionConstIterator<TInputImage> iRegIter;
ImageRegionIterator<TOutputImage> oRegIter;
iRegIter = ImageRegionConstIterator<InputImageType>(this->GetInput(), outputRegionForThread);
oRegIter = ImageRegionIterator<OutputImageType>(this->GetOutput(), outputRegionForThread);
RegionType requestedRegion = this->GetOutput()->GetRequestedRegion();

auto iRegIter = ImageRegionConstIterator<InputImageType>(this->GetInput(), requestedRegion);
auto oRegIter = ImageRegionIterator<OutputImageType>(this->GetOutput(), requestedRegion);
/* Copy the input image to the output image - then only boundary pixels
* need to be changed in the output image */
while (!oRegIter.IsAtEnd())
Expand All @@ -122,7 +116,14 @@ ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::DynamicThreaded
++oRegIter;
++iRegIter;
}
}


template <typename TInputImage, typename TOutputImage, typename TKernel>
void
ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::DynamicThreadedGenerateData(
const OutputImageRegionType & outputRegionForThread)
{
// Find the boundary "faces"
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType> fC;
typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType faceList =
Expand Down

0 comments on commit 08bc946

Please sign in to comment.