Reproducible Slicer crash when pushing to some volume nodes using sitkUtils PushVolumeToSlicer

I have run into a reproducible Slicer crash when using sitkUtils PushVolumeToSlicer(). If the output volume node exists and has some characteristic, then Slicer crashes. I have not been able to figure out what the characteristic is which leads to the crash, but I have several example volumes that this occurs for. The crash does not occur for the MRHead example volume.

The crash also occurs when using the SimpleFilters module, so it does not have to do with my code. Any time one of these volumes is selected as the “Output Volume”, running the filter leads to a crash.

If I crop one of the suspect volumes using the CropVolume module, the cropped version works fine as an “Output Volume” of the SimpleFilters module and in my code; it is only the uncropped original which causes problems. It also works fine if one of the problem volumes is the “Input Volume” for the filter, the problem only occurs if a problem volume is set as the “Output Volume”.

I have an anonymized minimal data set that can demonstrate the problem, but it is a head MR which includes the face, so I cannot share it publicly, and when I modify it (e.g. by cropping) the crash no longer occurs. If someone can take a look at this privately I would greatly appreciate it. Thanks!

I found a workaround. I created a temporary node, applied the filter so that the output went to the temporary node, and then linked the problematic node to the temporary node’s imagedata, and then removed the temporary node. This did not lead to a crash.

# Code used for exploring SITK crash bug
import SimpleITK as sitk
import sitkUtils

inputVolNode = getNode('vtkMRMLScalarVolumeNode130')
tempNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLScalarVolumeNode', 'tempVol')

wantACrash = False # change to true if you want a crash

inputImage = sitkUtils.PullVolumeFromSlicer(inputVolNode)
filt = sitk.NormalizeImageFilter()
outputImage = filt.Execute(inputImage)
if wantACrash:
  # The next line causes a crash
  sitkUtils.PushVolumeToSlicer(outputImage, inputVolNode)
else:
  # This section causes no problems
  sitkUtils.PushVolumeToSlicer(outputImage, tempNode)
  inputVolNode.SetAndObserveImageData(tempNode.GetImageData())
  slicer.mrmlScene.RemoveNode(tempNode)

After some investigation, it was determined that the “Sandbox” extension is the culprit. Disabling that extension is another way to avoid the crash.

The root cause of the problem has been fixed now:

1 Like