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

David Cole david.cole at kitware.com
Thu May 22 11:05:51 EDT 2008


Why are you calling SetOutput(NULL) on a reader object? The reader will
clean up after itself when it is deleted, you do not need to call
SetOutput(NULL). Did you see this as an example somewhere?



On Thu, May 22, 2008 at 8:53 AM, Maarten Nieber <hallomaarten at yahoo.com>
wrote:

> 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
>
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080522/4f2e9443/attachment.htm>


More information about the vtkusers mailing list