Page MenuHomePhabricator

OverwriteSliceImageFilter leads to deadlock: test was disabled
Closed, ResolvedPublic

Description

With the introduction of image accessors and their included lock-mechanism, the OverwriteSliceImageFilterTest fails due to a deadlock.

Since macros like AccessByItk use image accessors implicitly, an improper handling of itk image pointers can lead to a deadlock.

Event Timeline

Unfortunately the SegmentationInterpolationTest depends on the OverwriteSliceImageFilterTest. Thus, it was necessary to disable that test too.

2D and 4D Tests seem to work properly. Deadlock occurs only in 3D Test.

The deadlock occurs in CompareImageSliceHelper::CompareSlice, which is called in line 111. A separate slice image created from ExtractImageFilter is compared with a slice of its 3D input image. However, CompareSlice tries to compare the 3D input image with itself. This behavior does not make any sense, is not intended and leads to a double access request from the same thread and thus to a deadlock.

Unfortunately it is unknown, why this behavior occurs. Before using an AccessByItk macro, the two slice images are different. Right before calling ImageToItk->Update(), which leads to the deadlock, the 3D image is stored in ImageToItk instead of the slice image, although ImageToItk->SetInput gets the slice.

Maybe this problem disappears when replacing ExtractImageFilter with ExtractSliceFilter. We don't know much about the ExtractImageFilter and it is deprecated anyway, so a replacement could be contemplated...

[c2493a]: Merge branch 'bug-13309-OverwriteSliceImageFilterTest'

Merged commits:

2012-10-24 14:27:23 Joseph Grres [0dcea1]
Reactivated test and repaired OverwriteSliceImageFilterTest

It wasn't necessary to replace ExtractImageFilter with ExtractSliceFilter.

We only had to add a Clone() call to make sure that the memory area of the 3D input image is different to the extracted 2D slice image.