On 22.09.2010 21:58, Sebastian Hoffmann wrote:
> Hi again.
> 
> My code segfaults when calling iPcLinearMovement.SetPath() in this code:
> 
>     def pccommandinput_moveplane1(self,pc,args):
>         p = csPath(2)
>         p.SetForwardVector (0, csVector3(1,0,0))
>         p.SetPositionVector(0, csVector3(-2,0,0))
>         p.SetUpVector      (0, csVector3(0,1,0))
>         p.SetTime          (0, 0.0)
>         p.SetForwardVector (1, csVector3(-1,0,0))
>         p.SetPositionVector(1, csVector3(2,0,0))
>         p.SetUpVector      (1, csVector3(0,1,0))
>         p.SetTime          (1, 1.0)
>         self.mover.SetPath(p)
> 
> Running celstart in gdb shows this call and code line to be the cause:
> 
> 0x00007fffe1d98861 in celPcLinearMovement::ExtrapolatePosition
> (this=0x7fffe34f8fb0, delta=0.104999997) at
> /home/baribal/src/CEL_latest/plugins/propclass/move/linmove.cpp:1093
> 1093      float end_time = path->GetTime (path->Length () - 1);

I looked into the generated Python bindings code.

What happens is that, behind the scenes, a “csPath*” is stored inside p.
So when p gets out of scope, a “delete” is done on the stored pointer.
Obviously this is wrong, since the SetPath() call stores a reference to
”p”. (It takes an iPath*.)

What _should_ happen is that, behind the scenes, a “csRef<>” should be
stored in p (resp. that, instead of a ”delete”, DecRef() should be used
when p is destroyed).
SWIG probably allows that. However, I have no idea to actually do that.

-f.r.

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Cel-main mailing list
Cel-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cel-main

Reply via email to