[Insight-users] bad free() reading Signa images

Neil Weisenfeld neil at bwh.harvard.edu
Wed May 9 18:05:18 EDT 2007


Hi all,

(devs maybe read the last paragraph)

Here's why using GE4ImageIO with itkImageSeriesReader causes core-dumps:

itkImageSeriesReader reader attempts to read in an image slice by  
slice, however GE4ImageIO, when given the filename of a single slice,  
***actually reads in the whole volume***

So while itkImageSeriesReader correctly allocates an output volume  
for the slice dimensions x #slices, it then reads the entire volume  
#slices many times obviously (well, not obviously, but see below)  
trampling over unallocated memory.

One solution is to use GE4ImageIO with itkImageReader, rather than  
itkImageSeriesReader, supply only the *first* filename in the series,  
and then let the internal magic pick up all of the slices.

Maybe stylistically, it would be good if the loop in  
itkImageSeriesReader that actually copies pixels checked both the  
input AND output arrays for IsAtEnd().  That would, at least, avoid  
the core dump.


Regards,
Neil







On May 8, 2007, at 2:29 PM, Neil Weisenfeld wrote:

>
> Hi all,
>
> I'm trying to read some Signa 4.x images using the GE4ImageIO and  
> this seems to result in:
>
> *** glibc detected *** free(): invalid pointer: 0x0000002a98ab1010 ***
>
> which is coming from the destruction of itkImportImageContainer.
>
>
> An e-mail that someone sent to this list in January about reading  
> Signa 5.x images yielded the response that the Insight Applications  
> program ConvertBetweenFileFormats does this, however it seems to me  
> that ConvertBetweenFileFormats uses GDCM to read DICOM series  
> images, but not Signa(?)
>
> Furthermore, the tests included for GE4ImageIO only test reading of  
> a single slice, not a series, so I'm wondering if there is actually  
> a bug.
>
> Here's the code excerpt.  ***NOTE: I've tried this both via factory  
> traversal and by specifying a GE4ImageIO "manually" and both  
> produce the same results.
>
> I'd appreciate any suggestions and apologise if I did something  
> incredibly stupid.
>
>
>
> Regards,
> Neil
>
>
>
>
>   itk::ObjectFactoryBase::RegisterFactory 
> ( itk::GEAdwImageIOFactory::New() );
>   itk::ObjectFactoryBase::RegisterFactory 
> ( itk::GE4ImageIOFactory::New() );
>   itk::ObjectFactoryBase::RegisterFactory 
> ( itk::GE5ImageIOFactory::New() );
>
>   typedef unsigned short PixelType;
>   typedef itk::Image< PixelType, 3> ImageType;
>   typedef itk::NumericSeriesFileNames GeneratorType;
>   typedef itk::ImageSeriesReader< ImageType > SeriesReaderType;
>
>   GeneratorType::Pointer names = GeneratorType::New();
>   names->SetStartIndex( start );
>   names->SetIncrementIndex( inc ) ;
>   names->SetEndIndex( end );
>   names->SetSeriesFormat( inpPat.c_str() );
>
>   SeriesReaderType::Pointer reader = SeriesReaderType::New();
>   reader->SetFileNames( names->GetFileNames() );
>
>   try
>     {
>     reader->SetDebug(true);
>     reader->Update();
>
>
> code trace:
>
> #0  0x000000329cf2e21d in raise () from /lib64/tls/libc.so.6
> (gdb) bt
> #0  0x000000329cf2e21d in raise () from /lib64/tls/libc.so.6
> #1  0x000000329cf2fa1e in abort () from /lib64/tls/libc.so.6
> #2  0x000000329cf63291 in __libc_message () from /lib64/tls/libc.so.6
> #3  0x000000329cf68eae in _int_free () from /lib64/tls/libc.so.6
> #4  0x000000329cf691f6 in free () from /lib64/tls/libc.so.6
> #5  0x000000329fcae20e in operator delete () from /usr/lib64/libstdc 
> ++.so.6
> #6  0x0000000000441e15 in ~ImportImageContainer (this=0x659f70)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/Common/itkImportImageContainer.txx:45
> #7  0x0000002a967ecf29 in itk::Object::UnRegister ()
>    from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/ 
> libITKCommon.so.3.2
> #8  0x00000000004324e4 in  
> itk::SmartPointer<itk::ImportImageContainer<unsigned long, unsigned  
> short>
>> ::UnRegister (this=0x65bc20)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/Common/itkSmartPointer.h:148
> #9  0x0000000000432109 in ~SmartPointer (this=0x65bc20)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/Common/itkSmartPointer.h:65
> #10 0x0000000000440373 in ~Image (this=0x65ba60)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/Common/itkImage.h:365
> #11 0x0000002a967ecf29 in itk::Object::UnRegister ()
>    from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/ 
> libITKCommon.so.3.2
> #12 0x0000002a967f8143 in itk::ProcessObject::~ProcessObject$base ()
>    from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/ 
> libITKCommon.so.3.2
> #13 0x0000000000430351 in ~ImageSource (this=0x659db0)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/Common/itkImageSource.h:178
> #14 0x0000000000448e74 in ~ImageFileReader (this=0x659db0)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/IO/itkImageFileReader.txx:46
> #15 0x0000002a967ecf29 in itk::Object::UnRegister ()
>    from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/ 
> libITKCommon.so.3.2
> #16 0x00000000004462b0 in  
> itk::SmartPointer<itk::ImageFileReader<itk::Image<unsigned short,  
> 3u>, itk::DefaultConvertPixelTraits<unsigned short> > >::UnRegister  
> (this=0x7fbfffecc0)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/Common/itkSmartPointer.h:148
> #17 0x0000000000444069 in ~SmartPointer (this=0x7fbfffecc0)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/Common/itkSmartPointer.h:65
> #18 0x000000000043e928 in  
> itk::ImageSeriesReader<itk::Image<unsigned short, 3u>  
> >::GenerateData (this=0x6428a0)
>     at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/ 
> InsightToolkit/IO/itkImageSeriesReader.txx:290
> #19 0x0000002a967f9516 in itk::ProcessObject::UpdateOutputData ()
>    from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/ 
> libITKCommon.so.3.2
> #20 0x0000000000428421 in main (argc=6, argv=0x7fbffff518)
>     at /home/ch116471/projects/svnwrk/crkit.org/trunk/tools/code/ 
> crlSlicesToVolume.cxx:80
>
> _______________________________________________
> 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