[vtkusers] Why does this segfault?

Shawn Waldon swaldon at cs.unc.edu
Sat Jun 1 10:18:01 EDT 2013


I only get the circular reference error on some operating systems.  Ubuntu,
for example does not give that error, it simply segfaults at that point in
the code.  On my Macbook, which gives the Circular Reference error,
according to valgrind, there are 4 or 5 invalid reads before the Circular
Reference error is printed.  As far as I can tell, when CircuitCheck is
called with a transform that has already been deleted, on some OSs it
returns that there is a circular reference depending on the OS's policy
about what happens to freed memory.

Looking at my code, there should never be a circular reference:
I create 3 transforms a, b, & c (trans1, trans2, trans3 in the code).  I
get the inverses to b & c.  Then the loop alternates between setting b to
some constant transform with Rotate() and Translate() and setting it so
that  b = a * c^-1.  b is never concatenated to anything, so there should
never be a circular reference, and b's inverse is only used to transform
some points/vectors.


On Fri, May 31, 2013 at 6:47 PM, Christopher Mullins <
christopher.mullins at kitware.com> wrote:

> I'm getting the following error:
>
> ERROR: In VTK/Common/Transforms/vtkTransform.cxx, line 242
> vtkTransform (0x7f81c94172c0): Concatenate: this would create a circular
> reference.
>
> pointing to this line [1].  Looks like it could be circuit you're creating
> when you concatenate those transforms in the loop, where CircuitCheck [2]
> is returning true.  If you use trans2->Concatenate(inv3->GetMatrix());
> instead of passing the transform directly it terminates correctly.  Maybe
> someone else would know more about why, but it could be because GetMatrix()
> calls Update().
>
> [1]
> https://github.com/Kitware/VTK/blob/master/Common/Transforms/vtkTransform.cxx#L242
> [2]
> http://www.vtk.org/doc/nightly/html/classvtkTransform.html#a47c335c53f0917826db0e17724508640
>
>
>
> On Fri, May 31, 2013 at 6:56 PM, Shawn Waldon <swaldon at cs.unc.edu> wrote:
>
>> Hello all,
>>
>> I have been using vtk for a project and I ran across a simple case where
>> I can delete a vtkLinearTransform that I have a smart pointer to by
>> concatenating it onto another transform and calling Identity on that
>> transform.  I have attached a stripped down example program the exhibits
>> the error.  Every time through the loop in the test program the inverse's
>> reference count is decremented somehow until it is deleted and the program
>> segfaults on the next call to TransformVector/TransformPoint.
>>
>> Does anyone have any idea what is going on here?
>>
>> Thank you,
>>
>> Shawn Waldon
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
>
> --
> Christopher Mullins
> R&D Engineer
> Kitware Inc.,
> 919.869.8871
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130601/2b792d5a/attachment.htm>


More information about the vtkusers mailing list