[Insight-users] Malloc errors with repeated image IO??

Karthik Krishnan Karthik.Krishnan at kitware.com
Wed Mar 22 01:51:22 EST 2006


On Tue, 2006-03-21 at 11:20 -0800, Zachary Pincus wrote:
> Can anyone confirm that these malloc errors exist for them when  
> running the test cases below? 

No malloc errors on my laptop: Debain 2.6.12-1-386 gcc version 4.0.3
valgrind didn't turn anything up either. 

The input image was 
Insight/Testing/Data/Baseline/IO/cthead1.tif

> I used a variety of tiff images to test  
> this, so maybe it is a tiff io problem?
> 
> Another possibility is that this task is outside the design range of  
> ITK, and there is some better way to read thousands of images off  
> disk and into memory?
> 
> Any insight into what's going on here would be rather helpful.
> 
> Zach
> 
> 
> 
> On Mar 19, 2006, at 6:43 PM, Zachary Pincus wrote:
> 
> > Hi folks,
> >
> > In the process of reading in many (!) image files and storing the  
> > resulting images away (as Image::Pointer objects in some list or  
> > vector), I have run into some strange malloc errors.
> >
> > Here are some test cases which seem to reproduce these errors. The  
> > code for the cases is at the end of this email; here follows  
> > descriptions of the tests and the malloc errors produced.
> >
> > I'm using a CVS checkout of ITK from shortly after the 2.6 release,  
> > on OS X 10.4.5. Everything is compiled with GCC 4.0.1.
> >
> > ******
> > Case 0: [BASELINE] In a loop, create an ImageFileReader (and give  
> > it a valid file to read), and call Update(). The FileReader is  
> > destroyed and created anew each loop.
> >
> > No errors are produced.
> >
> >
> > ******
> > Case 1: In a loop, create an ImageFileReader, call Update(), and  
> > store the resulting image pointer in a std::vector. The FileReader  
> > is destroyed and created anew each loop.
> >
> > The errors are a flood of identical lines (down to the object  
> > address), e.g.:
> >> itkTest(18420) malloc: *** error for object 0x7801600: incorrect  
> >> checksum for freed object - object was probably modified after  
> >> being freed, break at szone_error to debug
> >> itkTest(18420) malloc: *** set a breakpoint in szone_error to debug
> >
> >
> > ******
> > Case 2: Create an ImageFileReader. In a loop, repeatedly call Update 
> > (), store the result away, and call DisconnectPipeline() so that  
> > the next loop through, a new image is created.
> >
> > The error is a few lines similar to those in case 1, and then other  
> > errors, culminating in an exception:
> >> itkTest(24609) malloc: *** error for object 0x780ee00: incorrect  
> >> checksum for freed object - object was probably modified after  
> >> being freed, break at szone_error to debug
> >> itkTest(24609) malloc: *** set a breakpoint in szone_error to debug
> >> itkTest(24609) malloc: ***  Deallocation of a pointer not  
> >> malloced: 0x80008; This could be a double free(), or free() called  
> >> with the middle of an allocated block; Try setting environment  
> >> variable MallocHelp to see tools to help debug
> >> TIFFFillStrip: /Users/zpincus/Documents/Research/Theriot Lab/ 
> >> Experimental Data/Catherine Keratocytes/Images3/summed/ 
> >> 022505_antiV_1.tif: Data buffer too small to hold strip 0.
> >>
> >> itk::ExceptionObject (0x756ec30)
> >> Location: "void itk::TIFFImageIO::ReadGenericImage(void*, unsigned  
> >> int, unsigned int)"
> >> File: /Users/zpincus/Developer/ITK/Insight/Code/IO/itkTIFFImageIO.cxx
> >> Line: 536
> >> Description: itk::ERROR: TIFFImageIO(0x7573530): Problem reading  
> >> the row: 0
> >
> > Does anyone have any thoughts as to what could be happening?
> >
> > Zach Pincus
> >
> >
> >
> > CODE FOR CASE 0:
> > ----------------
> > #include "itkImage.h"
> > #include "itkImageFileReader.h"
> > #include <iostream>
> >
> > typedef itk::Image<float, 2> FImage;
> > typedef itk::ImageFileReader<FImage> FReader;
> >
> > int main(int argc, char* argv[] )
> > {
> >   if (argc < 2) return -1;
> >
> >   for (int i = 0; i < 1000; i++)
> >     {
> >       try {
> >         FReader::Pointer fr = FReader::New();
> >         fr->SetFileName(argv[1]);
> >         fr->Update();
> >       } catch( itk::ExceptionObject & err ) {
> >         std::cout << err << std::endl;
> >         return -1;
> >       }
> >     }
> >   return 0;
> > }
> >
> > CODE FOR CASE 1:
> > ----------------
> > #include "itkImage.h"
> > #include "itkImageFileReader.h"
> > #include <iostream>
> > #include <vector>
> >
> > typedef itk::Image<float, 2> FImage;
> > typedef itk::ImageFileReader<FImage> FReader;
> > typedef std::vector<FImage::Pointer> FIPVector;
> >
> > int main(int argc, char* argv[] )
> > {
> >   if (argc < 2) return -1;
> >
> >   FIPVector vec;
> >   for (int i = 0; i < 1000; i++)
> >     {
> >       try {
> >         FReader::Pointer fr = FReader::New();
> >         fr->SetFileName(argv[1]);
> >         fr->Update();
> >         vec.push_back(fr->GetOutput());
> >       } catch( itk::ExceptionObject & err ) {
> >         std::cout << err << std::endl;
> >         return -1;
> >       }
> >     }
> >   return 0;
> > }
> >
> > CODE FOR CASE 2:
> > ----------------
> > #include "itkImage.h"
> > #include "itkImageFileReader.h"
> > #include <iostream>
> > #include <vector>
> >
> > typedef itk::Image<float, 2> FImage;
> > typedef itk::ImageFileReader<FImage> FReader;
> > typedef std::vector<FImage::Pointer> FIPVector;
> >
> > int main(int argc, char* argv[] )
> > {
> >   if (argc < 2) return -1;
> >
> >   FIPVector vec;
> >   FReader::Pointer fr = FReader::New();
> >   fr->SetFileName(argv[1]);
> >   for (int i = 0; i < 1000; i++)
> >     {
> >       try {
> >         fr->Update();
> >         vec.push_back(fr->GetOutput());
> >         fr->GetOutput()->DisconnectPipeline();
> >       } catch( itk::ExceptionObject & err ) {
> >         std::cout << err << std::endl;
> >         return -1;
> >       }
> >     }
> >   return 0;
> > }
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list