[Insight-developers] Harmless (?) valgrind errors on DeformableRegistration7

Karthik Krishnan Karthik.Krishnan at kitware.com
Mon Oct 3 08:27:56 EDT 2005


This was fixed in CVS a while ago:
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkArray.txx?root=Insight&r1=text&tr1=1.31&r2=text&tr2=1.30&diff_format=h

Now that you mentioned it, I just patched the ITK-2-2 release as well.
The patch is only on CVS.

To checkout ITK-2-2,
cvs -d:pserver:anonymous at www.itk.org:/cvsroot/Insight login
(passwd: insight)
cvs -d:pserver:anonymous at www.itk.org:/cvsroot/Insight co \
-r ITK-2-2 Insight

Or if you are already using CVS just
cvs up -r ITK-2-2 

Thanks
-karthik

On Mon, 2005-10-03 at 12:17 +0100, Kris Thielemans wrote:
> Hi
> 
> I've run valgrind --tool=memcheck on the executable for
> Examples/Registration/DeformableRegistration7.cxx that I make on my debian
> system (ITK 2.2, unfortunately using gcc 2.95.4, but I don't think it
> matters).
> 
> I get errors like this:
> 
> ==28336== 
> ==28336== Use of uninitialised value of size 8
> ==28336==    at 0x833B35E: vnl_vector<double>::operator=(vnl_vector<double>
> const &)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Utilities/vxl/core/vnl/vnl_v
> ector.txx:391)
> ==28336==    by 0x813CC8D: itk::Array<double>::operator=(itk::Array<double>
> const &)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Common/itkArray.txx:167
> )
> ==28336==    by 0x813D67B: itk::ImageRegistrationMethod<itk::Image<float,
> 3>, itk::Image<float, 3> >::ImageRegistrationMethod(void)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Algorithms/itkImageRegi
> strationMethod.txx:44)
> ==28336==    by 0x818EDFC: itk::ImageRegistrationMethod<itk::Image<float,
> 3>, itk::Image<float, 3> >::New(void)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Algorithms/itkImageRegi
> strationMethod.h:73)
> ==28336== 
> ==28336== Use of uninitialised value of size 8
> ==28336==    at 0x833B35E: vnl_vector<double>::operator=(vnl_vector<double>
> const &)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Utilities/vxl/core/vnl/vnl_v
> ector.txx:391)
> ==28336==    by 0x813CC8D: itk::Array<double>::operator=(itk::Array<double>
> const &)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Common/itkArray.txx:167
> )
> ==28336==    by 0x813D6BC: itk::ImageRegistrationMethod<itk::Image<float,
> 3>, itk::Image<float, 3> >::ImageRegistrationMethod(void)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Algorithms/itkImageRegi
> strationMethod.txx:45)
> ==28336==    by 0x818EDFC: itk::ImageRegistrationMethod<itk::Image<float,
> 3>, itk::Image<float, 3> >::New(void)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Algorithms/itkImageRegi
> strationMethod.h:73)
> Intial Parameters = 
> 
> 
> <snip>
> 
> 
> ==28336== 
> ==28336== Use of uninitialised value of size 8
> ==28336==    at 0x833B35E: vnl_vector<double>::operator=(vnl_vector<double>
> const &)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Utilities/vxl/core/vnl/vnl_v
> ector.txx:391)
> ==28336==    by 0x813CC8D: itk::Array<double>::operator=(itk::Array<double>
> const &)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Common/itkArray.txx:167
> )
> ==28336==    by 0x817D409:
> itk::MeanSquaresImageToImageMetric<itk::Image<float, 3>, itk::Image<float,
> 3> >::GetValueAndDerivative(itk::Array<double> const &, double &,
> itk::Array<double> &) const
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Algorithms/itkMeanSquar
> esImageToImageMetric.txx:292)
> ==28336==    by 0x819783B: itk::LBFGSBOptimizer::StartOptimization(void)
> (/data/home/kris/devel/ITK/InsightToolkit-2.2.0/Code/Numerics/itkLBFGSBOptim
> izer.cxx:287)
> 
> 
> 
> The first 2 come from the following lines in itkImageRegistrationMethod.txx:
> 
>   m_InitialTransformParameters = ParametersType(1);
>   m_LastTransformParameters = ParametersType(1);
> 
> I suppose this is because the constructor of ParametersType==Array<double>
> does not initialise the values. So, probably the code is really ok, but
> having a valgrind error feels a bit strange.
> 
> If these members really have to be initialised with an array of length 1 (I
> can't see why, but what do I know?) then I believe one solution would be to
> rewrite the constructor
> 
> template < typename TFixedImage, typename TMovingImage >
> ImageRegistrationMethod<TFixedImage,TMovingImage>
> ::ImageRegistrationMethod()
>  : m_InitialTransformParameters (1),
>    m_LastTransformParameters(1)
> {
>  //etc
> }
> 
> which is generally considered cleaner practice anyway.
> 
> 
> 
> The last error comes from a similar line
> 
>   derivative = DerivativeType( ParametersDimension );
> 
> This is not in a constructor, so the above trick doesn't work. However, as
> that line is followed by
> 
>    derivative.Fill( NumericTraits<ITK_TYPENAME
> DerivativeType::ValueType>::Zero );
> 
> I believe it would be best to replace both lines with
> 
>    derivative = DerivativeType( ParametersDimensio,
>                                  NumericTraits<ITK_TYPENAME
> DerivativeType::ValueType>::Zero );
> 
> (and similar for the lines in the constructor above).
> 
> 
> It seems all a consequence of the fact that Array doesn't have a resize().
> So, probably there are countless of these around.
> 
> 
> All the best
> 
> Kris Thielemans
> Hammersmith Imanet, part of GE Healthcare
> United Kingdom
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers



More information about the Insight-developers mailing list