← Back to team overview

yade-dev team mailing list archive

ScGeom6D crasher

 

Hi Bruno,

we were just reading the ScGeom6D code and there a serious bug. Suppose
a potential interaction of 2 spheres; Ig2_Sphere_Sphere_ScGeom6D::go
calls Ig2_Sphere_Sphere_ScGeom::go, which, if it succeeds, creates a new
ScGeom object and assigns it to I->geom. Then the execution goes back to
Ig2_Sphere_Sphere_ScGeom6D::go, which will cast I->geom to ScGeom6D!
This is not a valid operation and if you run in debug mode, the
YADE_PTR_CAST will return NULL pointer. (

If you want to avoid code duplication, the common function must know
what IGeom object to create, via a function argument; and since one
cannot change the signature of ::go (otherwise the virtual call would
call a different function), the common functionality must be in a
separate function called from both ::go functors, but with different
parameters.

You can have a look at Ig2_Sphere_Sphere_L3Geom and
Ig2_Sphere_Sphere_L6Geom for inspiration.

Cheers, cv






Follow ups