[vtkusers] Debugging a Segfault

Peter F Bradshaw pfb at exadios.com
Wed Mar 29 11:34:15 EST 2006


Hi;

On Wed, 29 Mar 2006, Martin Baumann wrote:

> Hi,
>
> I have a segfault in an application that uses vtk.
>
> strace writes:
> ...
> read(7, "\1\215E\201\5\0\0\0\0\0\0\0^\23\0\0002\2d\0X\2&\2\1\0\0"..., 32) = 32
> read(7, "\1\0\0\0", 4)                  = 4
> read(7, "2\2d\0\212\4\212\2", 8)        = 8
> read(7, "2\2d\0\212\4\212\2", 8)        = 8
> ioctl(9, 0x4008642a, 0xbfffce00)        = 0
> ioctl(9, 0x40186443, 0xbfffce10)        = 0
> ioctl(9, 0xc0046444, 0xbfffcd94)        = 0
> ioctl(9, 0x40046445, 0xbfffcd48)        = 0
> ioctl(9, 0x40046445, 0xbfffce78)        = 0
> write(7, "\217\5\4\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 16
> read(7, "\34\0E\201\2\0 \4K\1\0\0Y\262\270\0\1\246\256\10\2\0 \4"..., 32) = 32
> read(7, "\34\365E\201\2\0 \4\367\0\0\0Y\262\270\0\0\0\0\0Y\262\270"..., 32) = 32
> read(7, "\34\0E\201\2\0 \4w\1\0\0Y\262\270\0\1\0\0\0Y\262\270\0"..., 32) = 32
> read(7, "\25\346E\201\2\0 \4\2\0 \4?\0\0\0\0\0\0\0\0\246\256\10"..., 32) = 32
> read(7, "\34\0E\201\2\0 \4q\0\0\0Y\262\270\0\1\0\0\0Y\262\270\0"..., 32) = 32
> read(7, "\34\365E\201?\0\0\0>\1\0\0Z\262\270\0\0\0\0\0\0\246\256"..., 32) = 32
> read(7, "\34\365E\201?\0\0\0?\1\0\0Z\262\270\0\0\0\0\0Z\262\270"..., 32) = 32
> read(7, 0xbfffcd40, 32)                 = -1 EAGAIN (Resource temporarily unavailable)
> select(8, [7], NULL, NULL, NULL)        = 1 (in [7])
> read(7, "\1\0F\201\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0008\366"..., 32) = 32
> munmap(0x44e29000, 495616)              = 0
> ioctl(9, 0x40086449, 0xbfffcd08)        = 0
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV +++
>
>
> Core file opened in Kdbg:
> HvsStreamlineOptionWidget (this=0x82ce980, parent=0x408ce448, name=0x20f2 <Address 0x20f2 out of bounds>) at qstring.h:687
> HvsPathlineActor (this=0x809dbf8, __vtt_parm=0xbfffe878) at hvs_pathline_actor.cc:66
>
>
> The output of stracs and core file don't help me at all.
>
>
> With the debugger I found out, that the segfault occurs during the following destructor:
> HvsPipeline::~HvsPipeline()
> {
>   _line_widget->delete()
>   _plane_widget->Delete();  // this is a vtkPlaneWidget, this causes the segfault
> }
>
> How can I find out what goes wrong?  What would be the best way?
> As you see I am new to debugging :-(
> Where can I find information on the reference counting system of vtk? I guess it hat something to do with this.

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).

>
> Thanks, M.B.

Cheers

-- 
Peter F Bradshaw, http://www.exadios.com, ICQ 75431157 (exadios).
Public key at www.exadios.com/pfb.pgp.key and www.exadios.com/pfb.gpg.key
Personal site: http://personal.exadios.com.
"I love truth, and the way the government still uses it occasionally to
 keep us guessing." - Sam Kekovich.



More information about the vtkusers mailing list