From: John G. <glo...@gm...> - 2010-08-04 11:04:05
|
Hello, I'm working on a Google Summer of Code project on PaGMO (http://sourceforge.net/apps/mediawiki/pagmo) where I need to instantiate a large number of similar ODE worlds and objects running in multithreaded environment. I ran into a problem with Python garbage collection of some of the objects. Basically it seemed that sometimes a world was being deallocated, calling dBodyDestroy and deallocating memory for a body, but the Python object was still calling its own dealloc and bodyDestroy (with a similar problem for Joints), and crashing with a segmentation fault. I have code that can reproduce it on OS X 10.5 with Python 2.6.5, but the same code doesn't crash with the same Python version on Ubuntu, so it could be something strange with Python garbage collection on the Mac. However, the following minor fix sorts the problem out, so I was hoping that it would be possible to get it checked in, unless someone has an alternative. cvs diff: Diffing src Index: src/body.pyx =================================================================== RCS file: /cvsroot/pyode/pyode/src/body.pyx,v retrieving revision 1.8 diff -r1.8 body.pyx 59c59 < if self.bid!=NULL: --- > if self.bid!=NULL and self.world: Index: src/joints.pyx =================================================================== RCS file: /cvsroot/pyode/pyode/src/joints.pyx,v retrieving revision 1.14 diff -r1.14 joints.pyx 124c124 < if self.jid!=NULL: --- > if self.jid!=NULL and self.world: Also, I'm not sure if you are aware, but the PyBrain project (http://pybrain.org/) has some small XODE additions, perhaps they could also be included at some stage soon? Here's the diff: cvs diff: Diffing xode Index: xode/body.py =================================================================== RCS file: /cvsroot/pyode/pyode/xode/body.py,v retrieving revision 1.5 diff -r1.5 body.py 0a1,2 > #@PydevCodeAnalysisIgnore > 205a208,217 > elif (name == 'cappedCylinder'): > radius = float(attrs.get('radius', 1.0)) > length = float(attrs['length']) > if (density is not None): > mass.setCappedCylinder(float(density), 3, radius, length) > elif (name == 'cylinder'): > radius = float(attrs.get('radius', 1.0)) > length = float(attrs['length']) > if (density is not None): > mass.setCylinder(float(density), 3, radius, length) 214a227 > Index: xode/geom.py =================================================================== RCS file: /cvsroot/pyode/pyode/xode/geom.py,v retrieving revision 1.5 diff -r1.5 geom.py 0a1,2 > #@PydevCodeAnalysisIgnore > 72c74 < raise NotImplementedError() --- > self._parseGeomCylinder(attrs) 88c90 < j = joint.Joint(nodename, self) --- > j = joint.Joint(nodeName, self) 181a184,200 > def _parseGeomCylinder(self, attrs): > def start(name, attrs): > if (name == 'ext'): > pass > else: > raise errors.ChildError('cylinder', name) > > def end(name): > if (name == 'cylinder'): > self._parser.pop() > > radius = float(attrs['radius']) > length = float(attrs['length']) > > self._setObject(ode.GeomCylinder, radius=radius, length=length) > self._parser.push(startElement=start, endElement=end) > 236c255 < --- > 245c264 < tri = int(attrs['ia'])-1, int(attrs['ib'])-1, int(attrs['ic'])-1 --- > tri = int(attrs['ia']) - 1, int(attrs['ib']) - 1, int(attrs['ic']) - 1 Thanks, John |