Page MenuHomePhabricator

ReduceContourSetFilter crashes with ITK 4.4.0
Closed, ResolvedPublic

Description

Problem:

ITK 4.4.0's itkProcessObject.cxx does a lot more checks in its SetNumberOfIndexedOutputs member function than previous versions of ITK used to do.

mitkReduceContourSetFilter.cpp:106 increases the number of outputs. It started out with 1 output (default) and finally there will be numberOfCells + 1 = 2 outputs. The last one will always be NULL. However, the number of outputs should only be numberOfCells and the last NULL one shouldn't even exist. Apparently, this has been noticed and corrected in line 116 (this->SetNumberOfIndexedOutputs(numberOfOutputs);)

And this is the very location where ITK 4.4.0 crashes. It checks that all outputs are not NULL and then removes/adds outputs until the number of outputs matches the argument. The NULL output that shouldn't have been there in the first place results in an assertion/crash.

Fix:
simply replacing

this->SetNumberOfIndexedOutputs(this->GetNumberOfIndexedOutputs() + 1);

by

this->SetNumberOfIndexedOutputs(numberOfOutputs + 1);

in line 106 solved the problem.

Event Timeline

I was not able to reproduce this crash. Could you provide us with the data or parameters where this is happening?
Thank you!

(In reply to Christoph Kolb from comment #1)

I was not able to reproduce this crash. Could you provide us with the data
or parameters where this is happening?
Thank you!

These are the exact steps to reproduce:

  1. start application
  2. open the segmentation plugin
  3. load any 3D-Image
  4. Create a new segmentation
  5. use the 'add' tool and draw anything in any slice

when releasing the mouse button it crashes for the reasons mentioned earlier

the file
http://docs.mitk.org/nightly-qt4/mitkReduceContourSetFilter_8cpp_source.html
still has the erroneous line 106

Remember: this bug only occurs with ITK 4.4.0 and probably later. Earlier versions do things differently in itkProcessObject.cxx and therefore are not affected.

Hope this could help!

New remote branch pushed: bug-15805-ReduceContoureSetFilterCrashFix

[f77b23]: Merge branch 'bug-15805-ReduceContoureSetFilterCrashFix'

Merged commits:

2013-09-19 13:28:07 Arthur Teimourian [2ea003]
Fixed problem