View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006840ITKpublic2008-04-17 14:252010-10-21 12:31
ReporterRyan Baumann 
Assigned ToBradley Lowekamp 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0006840: ImageFileReader::DoConvertBuffer/ConvertPixelBuffer segfaults if numberOfPixels > INT_MAX
DescriptionTrying to do a file read which requires a buffer conversion with more than INT_MAX elements/pixels causes a segmentation fault (INT_MAX is defined as 2147483647 on most architectures). This is because all the functions in ConvertPixelBuffer take a size argument as a signed integer, so DoConvertBuffer performs a static_cast to int on the unsigned long numberOfPixels. An easy workaround is to remove the static casts and change all ConvertPixelBuffer functions to use an unsigned long for "size". It may, however, be preferable to instead use a type such as size_t.

Attached is a patch against 3.4.0, though the bug is still present in 3.6.0.
Additional InformationImageReadWrite example, modified to PixelType float and Dimension = 3, reading a 2000 x 2000 x 537 NRRD of type short:

Debug: In /home/baumann/source/educe/Seg3D/thirdparty.bin/3.1.0/Linux/gcc-4.2.3-64bit/include/InsightToolkit/IO/itkImageFileReader.txx, line 311
ImageFileReader (0x7139f0): StreamableRegion set to =ImageRegion (0x713b00)
  Dimension: 3
  Index: [0, 0, 0]
  Size: [2000, 2000, 537]


Debug: In /home/baumann/source/educe/Seg3D/thirdparty.bin/3.1.0/Linux/gcc-4.2.3-64bit/include/InsightToolkit/Common/itkProcessObject.h, line 271
ImageFileReader (0x7139f0): returning ReleaseDataBeforeUpdateFlag of 0

Debug: In /home/baumann/source/educe/Seg3D/thirdparty.bin/3.1.0/Linux/gcc-4.2.3-64bit/include/InsightToolkit/IO/itkImageFileReader.txx, line 324
ImageFileReader (0x7139f0): ImageFileReader::GenerateData()
Allocating the buffer with the StreamableRegion
ImageRegion (0x713b00)
  Dimension: 3
  Index: [0, 0, 0]
  Size: [2000, 2000, 537]



Debug: In /home/baumann/source/educe/Seg3D/thirdparty.bin/3.1.0/Linux/gcc-4.2.3-64bit/include/InsightToolkit/IO/itkImageFileReader.txx, line 354
ImageFileReader (0x7139f0): ioRegion: ImageIORegion (0x7fff30d31db0)
  Dimension: 3
  Index: 0 0 0
  Size: 2000 2000 537


Debug: In /home/baumann/source/educe/Seg3D/thirdparty.bin/3.1.0/Linux/gcc-4.2.3-64bit/include/InsightToolkit/IO/itkImageFileReader.txx, line 370
ImageFileReader (0x7139f0): Buffer conversion required.

Debug: In /home/baumann/source/educe/Seg3D/thirdparty.bin/3.1.0/Linux/gcc-4.2.3-64bit/include/InsightToolkit/IO/itkImageFileReader.txx, line 381
ImageFileReader (0x7139f0): Buffer conversion required from: s to: f

Segmentation fault (core dumped)
TagsNo tags attached.
Resolution Date
Sprint
Sprint Status
Attached Filespatch file icon itkbug.patch [^] (11,047 bytes) 2008-04-17 14:25 [Show Content]

 Relationships


 Issue History
Date Modified Username Field Change
2008-04-17 14:25 Ryan Baumann New Issue
2008-04-17 14:25 Ryan Baumann File Added: itkbug.patch
2009-02-03 14:03 Bradley Lowekamp Status new => assigned
2009-02-03 14:03 Bradley Lowekamp Assigned To => Bradley Lowekamp
2009-08-13 09:28 Bradley Lowekamp Note Added: 0017115
2009-08-13 09:28 Bradley Lowekamp Note Added: 0017116
2009-08-13 09:28 Bradley Lowekamp Status assigned => resolved
2009-08-13 09:28 Bradley Lowekamp Resolution open => fixed
2010-10-21 12:31 Gabe Hart Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team