[ODE] TriMesh bug

Joe Ante joeante at liquiddestiny.com
Mon Jul 14 15:58:02 2003


Hi,

There is a bug that causes double freeing in the trimesh code.
The problem as far as I can see comes up when pushing an element causes a
realloc inside dArray, which copys bytewise not using operator = which
causes SphereTC which is derived from Opcode:: VolumeCache which contains
Container            TouchedPrimitives;    //!< Indices of touched
Which has ptrs inside it and needs to be copied using operator = instead of
memcpy. This illegal memcpy causes the ptrs to be double and then causes a
double deallocation at some point.

Note that this is only a guess but I am pretty sure that this is causing the
double dealloc.

For now I just disabled caching and create a new sphere cache on every
collision, which works fine.

I can make a fixed size LRU cache if there is interest but I am not sure
that the caches gain a lot of performance anyway.

Also I think having one cache per sphere/box geom which is stored directly
inside the sphere/box geom might be the best solution, like pierre
suggested. This would of course make spheres and boxes be dependent on
trimeshes but we can do it inside a #ifdef. Will such a solution be allowed
to be passed into cvs by Russ?

Joe Ante

#0  0x8c902cb8 in malloc_printf ()
#1  0x8c9055a4 in unlockedfree ()
#2  0x8c905690 in free ()
#3  0x00467408 in operator delete(void*) ()
#4  0x004673a4 in operator delete[](void*) ()
#5  0x0018ef50 in IceCore::Container::Empty() ()
#6  0x0018f0f0 in IceCore::Container::SetSize(unsigned) ()
#7  0x0018f1a8 in IceCore::Container::operator=(IceCore::Container const&)
()
#8  0x0045b5d4 in Opcode::VolumeCache::operator=(Opcode::VolumeCache const&)
()
#9  0x0045bda8 in Opcode::SphereCache::operator=(Opcode::SphereCache const&)
()
#10 0x0045bd5c in dxTriMesh::SphereTC::operator=(dxTriMesh::SphereTC const&)
()
#11 0x0045bd20 in dArray<dxTriMesh::SphereTC>::push(dxTriMesh::SphereTC) ()
#12 0x00142604 in dCollideSTL(dxGeom*, dxGeom*, int, dContactGeom*, int) ()
#13 0x001379ec in dCollide ()
#14 0x0002da70 in DynamicsManager::NearCallback(void*, dxGeom*, dxGeom*) ()
#15 0x001388e4 in collideAABBs(dxGeom*, dxGeom*, void*, void (*)(void*,
dxGeom*, dxGeom*)) ()
#16 0x001391e8 in dxSimpleSpace::collide(void*, void (*)(void*, dxGeom*,
dxGeom*)) ()
#17 0x00139648 in dSpaceCollide ()