[Insight-users] HEAP CORRUPTION DETECTED:after Normal block ....

Luis Ibanez luis.ibanez at kitware.com
Thu Nov 26 12:39:20 EST 2009


Hi Motes,


Option A:  compile for Debug and run it from "gdb".
                 That will show you at what point you are
                 trying to write outside of the heap.


Option B: run it with Valgrind.
                 This will show you if you are writing outside of
allocated buffers.



      Regards,


                Luis


--------------------------------------------------------------------
On Tue, Nov 24, 2009 at 4:08 PM, motes motes <mort.motes at gmail.com> wrote:
> I am starting to get some rather nasty memory related errors in my itk
> application. The error message is:
>
>
>
> HEAP CORRUPTION DETECTED:after Normal block(#107261) at 0x020A44E0.
> CRT detected that the application wrote to memory after end of heap
> buffer.
>
>
>
> It happens when I try to compute the registered image after the
> registration process is finished. The code for this looks like this:
>
>  void computeRegisteredImage(){
>    std::cout << "INFO:: Computing registered image" << std::endl;
>    resampler->SetInput(imageM);
>    resampler->SetTransform(registration->GetTransform());
>    resampler->SetInterpolator(registration->GetInterpolator());
>    resampler->SetOutputOrigin(imageF->GetOrigin());
>    resampler->SetOutputSpacing(imageF->GetSpacing());
>    resampler->SetSize(imageF->GetLargestPossibleRegion().GetSize());
>    resampler->SetDefaultPixelValue(default_pixel_value);
>    resampler->Update();
>    CopyImageToImage<typename FixedImageType::Pointer,
> FixedImageType>(resampler->GetOutput(), imageR);
>  }
>
>
> Now the resampler uses the transform. I have created my own transform
> that make use of the itk::kdtree:
>
> template<class TScalarType, unsigned int NDimensions, unsigned int VSplineOrder>
> void
> MyTransform<TScalarType, NDimensions, VSplineOrder>
> ::TransformPoint(
>  const InputPointType & point,
>  OutputPointType & outputPoint,
>  WeightsType & weights,
>  ParameterIndexArrayType & indices,
>  bool & inside ) const
> {
>  unsigned int j;
>  IndexType supportIndex;
>  inside = true;
>  InputPointType transformedPoint;
>
>  if ( m_BulkTransform ) {
>    transformedPoint = m_BulkTransform->TransformPoint( point );
>  } else {
>    transformedPoint = point;
>  }
>
>  outputPoint.Fill( NumericTraits<ScalarType>::Zero );
>  if ( m_CoefficientImage[0] ) {
>    outputPoint.Fill( NumericTraits<ScalarType>::Zero );
>
>
>    NeighborContainerType neighbors;
>    this->FindNeighbors(point, m_kernel_radius, neighbors);
>
>
> where FindNeighbors is:
>
>
> template<typename TScalarType, unsigned int NDimensions, unsigned int
> VSplineOrder>
> void
> MyTransform<TScalarType, NDimensions, VSplineOrder>
> ::FindNeighbors(const InputPointType & point, double radius,
> NeighborContainerType & neighborControlPoints) const
> {
>  VectorContainerType neighbors;
>  InputPointType tmp;
>  tmp.Fill( NumericTraits<ScalarType>::Zero );
>  VectorType vectorPoint = point - tmp;
>  m_kdTree.search(vectorPoint, radius, neighbors);
>
>
>
> and search is:
>
>  void search(MeasurementVectorType & queryPoint, double & radius,
> NeighborContainerType & neighborsContainer) {
>    NeighborsType neighbors;
>    tree->Search(queryPoint, radius, neighbors );
>
>
> It works fine when I use it during the registration process but not
> when it come to the resampling process. Any ideas on what might be
> causing this kind of error and how to locate it?
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list