[vtkusers] Debugging a Segfault

Martin Baumann mailsgetlost at web.de
Thu Mar 30 17:29:25 EST 2006


Hi,

I am using KDbg. I guess that I did what you meant:
I set a stop point on the line that causes the error. I opened the 
window that show the local variables.
Next to _plane_widget stands 0x832aee0. So not 0.

To make sure _plane_widget is referenced only once I did the following:
  std::cout << "LW: " << _line_widget->GetReferenceCount() << std::endl;
  _line_widget ->Delete();
  std::cout << "PW: " << _plane_widget->GetReferenceCount() << std::endl;
_plane_widget->Delete(); // This causes the SIGFAULT

This lead to the following output:
  LW: 1
  PW: 1

Hmmm...

Thanks, M.B.


Peter F Bradshaw schrieb:

>
>Step one is to determine the value of _plane_widget. My guess is that it
>is 0 (i.e. 0x0). The value of _plane_widget may be examined by
>"printing" it - however that's done in Kdbg. Using gdb you would type:
>
>p _plane_widget
>
>in the context of the segfault.
>
>The reason that _plane_widget may be zero is because it was initally
>asigned that value when it was declared and there has been no
>
>_plane_widget = vtkPlaneWidget::New();
>
>However, as you point out, it may be that you are deleting an object
>that no longer exists. That is it has been deleted elsewhere. You can
>examine the reference count of _plane_widget at any time by something
>like:
>
>  cout << _plane_widget->GetReferenceCount() << endl;
>
>If the value of GetReferenceCount() is 1 just before Delete() then the
>Delete() will really delete the object.
>
>Vtk reference counting is normally handled in vtkObjectBase (assuming
>no overloading).
>



More information about the vtkusers mailing list