View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008371ITKpublic2009-01-13 11:572010-10-21 14:13
ReporterBradley Lowekamp 
Assigned ToBradley Lowekamp 
PrioritynormalSeverityminorReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0008371: large MetaImage files and 32-bit produces erroneous results
DescriptionWhen using streaming and 4GB+ file and a 32-bit build only the first 4 GB are read. Requested regions beyond that appear to be read mod 32-bit, that is they go back to the beginning of the file. This should be able to be reproduced with the itkImageFileWriterStreamingTest1 with a 4GB+ file.
TagsNo tags attached.
Resolution Date
Sprint
Sprint Status
Attached Files

 Relationships
related to 0009260assignedLuis Ibanez Integer types inconsistency in 64 bits platforms 

  Notes
(0014547)
Bradley Lowekamp (developer)
2009-01-13 12:00
edited on: 2009-01-14 17:26

Searching for problematic code, (ie incorrect usage of size_t) I made the following changes which may fix this bug:

Index: metaImage.cxx
===================================================================
RCS file: /cvsroot/Insight/Insight/Utilities/MetaIO/metaImage.cxx,v
retrieving revision 1.107
diff -r1.107 metaImage.cxx
1901c1901
< size_t endfile = tmpWriteStream->tellp();
---
> unsigned long endfile = tmpWriteStream->tellp();
1904c1904
< size_t padding = seekpos-endfile;
---
> unsigned long padding = seekpos-endfile;
2129c2129
< size_t padding = seekpos-currentPos;
---
> unsigned long padding = seekpos-currentPos;

*not the fix, but wrong types are still used*

(0014554)
Bradley Lowekamp (developer)
2009-01-14 14:41

I have been able to reproduce this on apple and linux systems
(0014555)
Bradley Lowekamp (developer)
2009-01-14 17:24
edited on: 2009-01-14 17:29

I have been able to track the problem down to the following on 32-bit systems:

sizeof(std::streamsize):4
sizeof(std::pos_type):16
sizeof(unsigned long):4

metaImage utilizes unsigned long for seeking and teling around files. This is now clearly the wrong type and the corrected type should be related to pos_type. Also calculations which are assigned to this type need to be casts to avoid overflow.

A quick local correction verified that this was the problem and this is the fix.

(0014571)
Mathieu Malaterre (developer)
2009-01-15 04:50

No, tellp() returns a streampos (castable to int):

http://www.cplusplus.com/reference/iostream/ostream/tellp.html [^]

Do not forget to provide a patch bor bcc compiler (yeah ITK supports old/broken compiler).

http://www.cmake.org/Wiki/CMake_Borland_Compiler_Issues [^]

 Issue History
Date Modified Username Field Change
2009-01-13 11:57 Bradley Lowekamp New Issue
2009-01-13 12:00 Bradley Lowekamp Note Added: 0014547
2009-01-14 14:41 Bradley Lowekamp Note Added: 0014554
2009-01-14 17:24 Bradley Lowekamp Note Added: 0014555
2009-01-14 17:25 Bradley Lowekamp Note Edited: 0014547
2009-01-14 17:26 Bradley Lowekamp Note Edited: 0014547
2009-01-14 17:29 Bradley Lowekamp Note Edited: 0014555
2009-01-15 04:50 Mathieu Malaterre Note Added: 0014571
2009-02-03 13:50 Bradley Lowekamp Status new => assigned
2009-02-03 13:50 Bradley Lowekamp Assigned To => Bradley Lowekamp
2009-11-22 10:00 Bradley Lowekamp Assigned To Bradley Lowekamp => Julien Jomier
2009-11-22 10:01 Bradley Lowekamp Relationship added related to 0009260
2010-10-21 14:13 Hans Johnson Assigned To Julien Jomier => Bradley Lowekamp


Copyright © 2000 - 2018 MantisBT Team