View Issue Details

IDProjectCategoryView StatusLast Update
0004416Slicer4Core: Diffusion and Tractography (Any modules)public2017-12-31 01:28
ReporterlassoanAssigned Toinorton 
Status assignedResolutionopen 
Product VersionSlicer 4.7.0 
Target VersionSlicer 4.9.0Fixed in Version 
Summary0004416: Crash when displaying DTI volume in slice view

When a DTI volume is shown in a slice view, then Slicer crashes as soon as the rendering pipeline is updated.

The crash occurs in vtkImageReslice:

    vtkImaging-7.1.dll!`anonymous namespace'::vtkInterpolateRound<double>(double val, double & rnd)  Line 1293 + 0xb bytes   C++
>   vtkImaging-7.1.dll!`anonymous namespace'::vtkImageResliceConversion<double,double>::Convert(void * & outPtr0, const double * inPtr, int numscalars, int n)  Line 1417    C++
    vtkImaging-7.1.dll!`anonymous namespace'::vtkReslicePermuteExecute<double>(vtkImageReslice * self, vtkDataArray * scalars, vtkAbstractImageInterpolator * interpolator, vtkImageData * outData, void * outPtr, double scalarShift, double scalarScale, void (void *, void *, int, int, int, int, int, int, int)* convertScalars, int * outExt, int threadId, double [4]* matrix)  Line 3017  C++
    vtkImaging-7.1.dll!vtkImageReslice::ThreadedRequestData(vtkInformation * __formal, vtkInformation * __formal, vtkInformation * __formal, vtkImageData * * * inData, vtkImageData * * outData, int * outExt, int threadId)  Line 3281    C++
    vtkCommon-7.1.dll!vtkThreadedImageAlgorithmThreadedExecute(void * arg)  Line 443    C++
    kernel32.dll!BaseThreadInitThunk()  + 0x14 bytes    
    ntdll.dll!RtlUserThreadStart()  + 0x21 bytes    

Maybe DTI volumes shouldn't be selected as volumes in the slice viewer? And/or vtkImageReslice should be fixed to not crash.

I've come across this issue when I tried to test this PR:

Steps To Reproduce

When this script into the Python console, Slicer crashes:

# Load volume
import SampleData
logic = SampleData.SampleDataLogic()
vol = logic.downloadFromSource(SampleData.SampleDataSource('dt-helix-ref-BS', '', 'dt-helix-ref-BS.nrrd', 'dt-helix-ref-BS.nrrd'))[0]

# Force rendering pipeline update
TagsNo tags attached.




2017-08-16 18:53

developer   ~0015053

The issue is not in the NRRD reader, as a .mha version of the file (attached) crashes the same way.
However, there is no crash when the volume is loaded directly using a VTK reader, only when loaded into a volume node.


[success,vol]=slicer.util.loadVolume(r'c:\D\S4\Modules\CLI\ResampleDTIVolume\Data\Baseline\dt-helix-ref-BS.mha', returnNode=True)
reslice = vtk.vtkImageReslice()

No crash:

reslice = vtk.vtkImageReslice()


2017-08-16 18:54


dt-helix-ref-BS.mha (711,933 bytes)


2017-12-30 22:57

developer   ~0015472

Last edited: 2017-12-30 23:18

View 2 revisions

backtrace for crash in

    frame #0: 0x0000000119dd9d02 libvtkImaging-7.1.1.dylib`void (anonymous namespace)::vtkReslicePermuteExecute<double>(self=0x000000014364a120, scalars=0x0000000000000000, interpolator=0x0000000144fc7c30, outData=0x0000000144fb2a00, outPtr=0x0000000127f1cf20, scalarShift=0, scalarScale=1, convertScalars=00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, outExt=0x000070000f4b7eb0, threadId=1, matrix=0x000070000f4b7d20)(void*, void*, int, int, int, int, int, int, int), int*, int, double (*) [4]) at vtkImageReslice.cxx:2837
   2835   // if doConversion is false, a special fast-path will be used
   2836   bool doConversion = true;
-> 2837   int inputScalarType = scalars->GetDataType();
   2838   if (interpolationMode == VTK_NEAREST_INTERPOLATION &&
   2839       inputScalarType == scalarType && !convertScalars && !rescaleScalars &&
   2840       nsamples == 1)


2017-12-30 23:06

developer   ~0015473

In the backtrace above, scalars is passed down null, soscalars->GetDataType() segfaults. I don't know if that is considered a bug in vtkImageReslice, but I think the assumption that the image has scalars attached is pervasive...

The origin of the crash is the lack of scalars attached to the vtkImageData by the reader, because the imagedata is storing tensors instead.

In interactive use, this works out fine (we use the DT slice view feature very often), because scalars are assigned by the tensor -> scalar filter pipeline in vtkMRMLDiffusionTensorVolumeSliceDisplayNode. I guess the crash happens when Modified() is called directly because the pipeline has not been updated.



2017-12-31 01:28

developer   ~0015474

It is definitely a bug in vtkImageReslice. It should be checked that "scalars" is non-null before it is used. It is done like that it many other filters where GetDataType() is used.

@inorton, could you add a null-pointer check into vtkImageReslice and submit a pull request to VTK? If not, then we may ask David Gobbi (author of this class) to get this fixed.

Issue History

Date Modified Username Field Change
2017-08-16 18:19 lassoan New Issue
2017-08-16 18:19 lassoan Status new => assigned
2017-08-16 18:19 lassoan Assigned To => inorton
2017-08-16 18:19 lassoan Description Updated View Revisions
2017-08-16 18:20 lassoan Description Updated View Revisions
2017-08-16 18:20 lassoan Steps to Reproduce Updated View Revisions
2017-08-16 18:53 lassoan Note Added: 0015053
2017-08-16 18:54 lassoan File Added: dt-helix-ref-BS.mha
2017-12-30 22:57 inorton Note Added: 0015472
2017-12-30 23:06 inorton Note Added: 0015473
2017-12-30 23:18 inorton Note Edited: 0015472 View Revisions
2017-12-31 01:28 lassoan Note Added: 0015474