scpeters-test / sdformat

Simulation Description Format (SDF) parser and description files.
http://sdformat.org
Other
1 stars 0 forks source link

URDF parsing seg-fault on OSX 10.8 #74

Open scpeters-test opened 9 years ago

scpeters-test commented 9 years ago

Original report (archived issue) by Steve Peters (Bitbucket: Steven Peters).


It's really weird; I'm only able reproduce this on my laptop running OSX 10.8.5. With the home-brew versions or urdfdom and console_bridge installed, and building the sdf_2.0 branch with -DUSE_EXTERNAL_URDF=True.

I observe seg-faulting of the INTEGRATION_fixed_joint_reduction and PERFORMANCE_parser_urdf tests.

From some extensive debugging, I've seen that the parser is unable to properly cast some of the URDF data types. For example, the cast from urdf::Geometry to urdf::Box in sdf::CreateGeometry is unsuccessful, which causes the seg-faults. The following is a workaround that prevents the seg-faults:

diff -r 675bd271feb80485067835704b966f8b57a8bf1c src/parser_urdf.cc
--- a/src/parser_urdf.cc    Fri Sep 12 11:13:09 2014 -0700
+++ b/src/parser_urdf.cc    Wed Oct 01 14:31:48 2014 -0700
@@ -1673,9 +1673,19 @@
         box = boost::dynamic_pointer_cast< const urdf::Box >(_geom);
         int sizeCount = 3;
         double sizeVals[3];
-        sizeVals[0] = box->dim.x;
-        sizeVals[1] = box->dim.y;
-        sizeVals[2] = box->dim.z;
+        if (box)
+        {
+          sizeVals[0] = box->dim.x;
+          sizeVals[1] = box->dim.y;
+          sizeVals[2] = box->dim.z;
+        }
+        else
+        {
+          std::cerr << "Failed to cast to urdf::BoxPtr" << std::endl;
+          sizeVals[0] = 1.0;
+          sizeVals[1] = 1.0;
+          sizeVals[2] = 1.0;
+        }
         geometryType = new TiXmlElement(type);
         AddKeyValue(geometryType, "size",
             Values2str(sizeCount, sizeVals));

This is really weird.

scpeters-test commented 9 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Is is possible to use _geom.get() to get a raw pointer to the box, and use static_cast?

scpeters-test commented 9 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters).


I'm not using OS X 10.8 anymore; on hold for now. Please comment or upvote if the issue affects you.