[ITK-dev] linear interpolator leaks?

M.Staring at lumc.nl M.Staring at lumc.nl
Wed Jun 1 03:45:08 EDT 2016


Hi all,

I noticed that our valgrind build of elastix has reports like this:

UMR ==5253== Invalid read of size 2
==5253==    at 0x552241: itk::LinearInterpolateImageFunction<itk::Image<short, 2u>, double>::EvaluateOptimized(itk::LinearInterpolateImageFunction<itk::Image<short, 2u>, double>::Dispatch<2u> const&, itk::ContinuousIndex<double, 2u> const&) const (itkLinearInterpolateImageFunction.h:173)
==5253==    by 0x54976C: itk::LinearInterpolateImageFunction<itk::Image<short, 2u>, double>::EvaluateAtContinuousIndex(itk::ContinuousIndex<double, 2u> const&) const (itkLinearInterpolateImageFunction.h:99)
==5253==    by 0x54397B: bool TestInterpolators<2u>() (itkAdvancedLinearInterpolatorTest.cxx:171)
==5253==    by 0x53E232: main (itkAdvancedLinearInterpolatorTest.cxx:279)
==5253==  Address 0x6822b94 is 52 bytes inside a block of size 83 free'd
==5253==    at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5253==    by 0x5ED884: itk::ObjectFactoryBase::CreateObject(char const*) (in /home/marius/nightly-builds/elastix/bin_debug/bin/itkAdvancedLinearInterpolatorTest)
==5253==    by 0x5EF91B: itk::ObjectFactoryBase::CreateInstance(char const*) (in /home/marius/nightly-builds/elastix/bin_debug/bin/itkAdvancedLinearInterpolatorTest)
==5253==    by 0x550335: itk::ObjectFactory<itk::LinearInterpolateImageFunction<itk::Image<short, 2u>, double> >::Create() (itkObjectFactory.h:60)
==5253==    by 0x548A90: itk::LinearInterpolateImageFunction<itk::Image<short, 2u>, double>::New() (in /home/marius/nightly-builds/elastix/bin_debug/bin/itkAdvancedLinearInterpolatorTest)
==5253==    by 0x543540: bool TestInterpolators<2u>() (itkAdvancedLinearInterpolatorTest.cxx:114)
==5253==    by 0x53E232: main (itkAdvancedLinearInterpolatorTest.cxx:279)
==5253==

On inspection these lines in itk LinearInterpolateImageFunction.h seem troublesome:

const RealType & val000 = inputImagePtr->GetPixel(basei);

Note that a real type is obtained by reference from a function that often does not return  a real type. Is this allowed?

Best, Marius

Marius Staring, PhD
Division of Image Processing (LKEB)
Department of Radiology
Leiden University Medical Center
PO Box 9600, 2300 RC Leiden, The Netherlands
phone: +31 (0)71 52 62137, fax: +31 (0)71 524 8256 m.staring at lumc.nl

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20160601/6cdd037d/attachment.html>


More information about the Insight-developers mailing list