From Patrick Hartling, "I encountered a bug related to RTTI for subclasses of osg::Shape. The
circumstances under which this bug occur are rather specific, but the basic problem occurs when one translation unit other than libosg.so constructs an object that is a subclass of osg::Shape and another translation unit other than libosg.so tries to perform a dynamic_cast or other RTTI-based operation on that object. Under these circumstances, the RTTI operation will fail. In my case, the translation units involved were an application and osgdb_ive.so. The application constructed a scene graph that included instantiations of subclasses of osg::Shape. Depending on how the user ran the application, it would write the scene graph to an IVE file using osgDB::writeNodeFile(). The dynamic_cast operations in DataOutputStream::writeShape() would fail on the first subclass of osg::Shape that was encountered. This is because there were two different RTTI data objects for all osg::Shape subclasses being compared: one in the application and one in osgdb_ive.so. The fix for this is simple. We must ensure that at least one member function of each of the subclasses of the polymorphic type osg::Shape is compiled into libosg.so so that there is exactly one RTTI object for that type in libosg.so. Then, all code linking against libosg.so will use that single RTTI object. The following message from a list archive sort of explains the issue and the solution: http://aspn.activestate.com/ASPN/Mail/Message/1688156 While the posting has to do with Boost.Python, the problem applies to C++ libraries in general."
This commit is contained in:
@@ -19,6 +19,46 @@ Shape::~Shape()
|
||||
{
|
||||
}
|
||||
|
||||
ShapeVisitor::~ShapeVisitor()
|
||||
{
|
||||
}
|
||||
|
||||
ConstShapeVisitor::~ConstShapeVisitor()
|
||||
{
|
||||
}
|
||||
|
||||
Sphere::~Sphere()
|
||||
{
|
||||
}
|
||||
|
||||
Box::~Box()
|
||||
{
|
||||
}
|
||||
|
||||
Cone::~Cone()
|
||||
{
|
||||
}
|
||||
|
||||
Cylinder::~Cylinder()
|
||||
{
|
||||
}
|
||||
|
||||
Capsule::~Capsule()
|
||||
{
|
||||
}
|
||||
|
||||
InfinitePlane::~InfinitePlane()
|
||||
{
|
||||
}
|
||||
|
||||
TriangleMesh::~TriangleMesh()
|
||||
{
|
||||
}
|
||||
|
||||
ConvexHull::~ConvexHull()
|
||||
{
|
||||
}
|
||||
|
||||
HeightField::HeightField():
|
||||
_columns(0),
|
||||
_rows(0),
|
||||
@@ -129,4 +169,7 @@ Vec2 HeightField::getHeightDelta(unsigned int c,unsigned int r) const
|
||||
return heightDelta;
|
||||
}
|
||||
|
||||
CompositeShape::~CompositeShape()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user