[vtkusers] Strange segfault with vtkMetaImageReader
Paul Melis
paul at science.uva.nl
Thu Apr 16 07:59:35 EDT 2009
Hi,
I'm using VTK 5.2 (Python interface) to read a bunch of .mhd/.raw pairs.
On each dataset I need to do the same processing so I have a pipeline
starting with a vtkMetaImageReader, followed by a vtkContourFilter and
some other things. I set the filename on the reader to the next file to
process and call Update() on the final filter in the pipeline and get
its output, then go on the next file, etc.
The strange problem I have is that the first file processes fine, but I
get a segfault for the second file, like this
MetaImage: M_ReadElements: data not read completely
ideal = 998784 : actual = 0
Segmentation fault (core dumped)
I double checked all the files being read and they have the correct
size, i.e. dimensions and file type specified in the .mhd file matches
the size of the corresponding .raw file.
If I do an strace of execution of the script shown at the end of this
post (which is a simplification from my actual processing script) I can
see that the second file (102x102x96 unsigned chars = 998784 bytes) is
actually not read fully using a single read() call. A second read() call
is used to read the remaining data, but the buffer location provided is
invalid, at least that's what read() returns:
[...]
write(1, "updating #2\n", 12) = 12
open("Segmentation_resampled_1mm_cropped_padded.mhd",
O_RDONLY|O_LARGEFILE) = 3
read(3, "ObjectType = Image\nNDims = 3\nBin"..., 8191) = 357
close(3) = 0
open("Segmentation_resampled_1mm_cropped_padded.mhd",
O_RDONLY|O_LARGEFILE) = 3
read(3, "ObjectType = Image\nNDims = 3\nBin"..., 8191) = 357
open("Segmentation_resampled_1mm_cropped_padded.raw",
O_RDONLY|O_LARGEFILE) = 4
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
998784) = 978936
read(4, 0xb7c8e000, 19848) = -1 EFAULT (Bad address)
[...]
And another strange thing is that when I don't ask the contour filter to
Update() the segfault does not happen and both files are correctly read...
Does anybody happen to have a clue what's going here? Is this a bug in
the metaimage reader?
Regards,
Paul
import vtk
dr = vtk.vtkMetaImageReader()
cf = vtk.vtkContourFilter()
cf.SetInputConnection(dr.GetOutputPort())
cf.SetValue(0, 128)
dr.SetFileName('Segmentation_resampled_1mm_cropped_padded15.mhd')
print 'updating #1'
dr.Update()
print dr.GetOutput().GetDimensions()
cf.Update()
dr.SetFileName('Segmentation_resampled_1mm_cropped_padded.mhd')
print 'updating #2'
# segfault...
dr.Update()
print dr.GetOutput().GetDimensions()
More information about the vtkusers
mailing list