[vtkusers] crash with structuredPointsReader->SetOutput(NULL)

Maarten Nieber hallomaarten at yahoo.com
Thu May 22 08:53:34 EDT 2008


Hi,

I wrote a test function that reproduces a crash with calling SetOutput(NULL) on a vtkStructuredPointsReader.
I'm using vtk 5.1.0 on Windows XP (by the way, I did not see a vtk version history, I wanted to check if my problem was solved in the latest version).

The program crashes with the message 'Access violation reading location 0x037ee000'.

The test function tries to detach the output from the reader. 
By now, I know a better way to detach an output by using the ShallowCopy function. Still, I would like to know if I'm doing something wrong, or if this is a bug in vtk.

    #include "vtkStructuredPoints.h"
    #include "vtkStructuredPointsReader.h"

    void TestToReproduceCrashWithVtkImageReader()
    {
        vtkStructuredPointsReader* reader = vtkStructuredPointsReader::New();
        reader->SetFileName("ironProt.vtk");
        reader->Update();
        vtkStructuredPoints* image = reader->GetOutput();
        image->Register(NULL);
        reader->SetOutput(NULL); // This line seems to cause problems
        reader->Delete();

        int imageSize = image->GetNumberOfPoints() * image->GetScalarSize();
        unsigned char* buffer = new unsigned char[imageSize];
       
         // The crash occurs in this line!
        memcpy(buffer, image->GetScalarPointer(), imageSize);
    }

Note that the test does not crash if I comment out the call to SetOutput(NULL).
Thanks!
Maarten


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080522/2199c81e/attachment.htm>


More information about the vtkusers mailing list