gazebosim / sdformat

Simulation Description Format (SDFormat) parser and description files.
http://sdformat.org
Apache License 2.0
161 stars 91 forks source link

gz sdf segmentation fault 11 due to conflict between <sensor> and <collision> tags #164

Open osrf-migration opened 7 years ago

osrf-migration commented 7 years ago

Original report (archived issue) by Nuno Guedelha (Bitbucket: gnuno).

The original report had attachments: singleLinkModel_V1.sdf, singleLinkModel_V1.urdf, singleLinkModel_V2.urdf


The issue can be reproduced on a simple URDF model defined by:

We run the urdf->sdf conversion as follows:

#!shell
gz sdf -p <model_file>.urdf > <model_file>.sdf

If the sensor is defined after the stiffness and bounce parameters (singleLinkModel_V1.urdf), the convertion runs successfully. If we invert the order, i.e. the sensor is defined before the collision/bounce parameters (singleLinkModel_V2.urdf), the commnd gz fails with a "segmentation fault 11".

osrf-migration commented 7 years ago

Original comment by Nuno Guedelha (Bitbucket: gnuno).


As a side note: there was no warning nor error message displayed on the terminal where Gazebo was launched from. We just got the application crash report on the Mac console. For additional information (including the crash report) please refer to the issue raised on github https://github.com/robotology-playground/icub-model-generator/issues/54.

osrf-migration commented 7 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


It doesn't seg-fault for me, but I can confirm the parsing error that depends on the order of the <gazebo> tags.

osrf-migration commented 7 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I think there is a bug in InsertSDFExtensionCollision.

osrf-migration commented 7 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


$ valgrind --tool=memcheck --verbose gz sdf -p singleLinkModel_V2.urdf
...
==32150== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
==32150== 
==32150== 1 errors in context 1 of 2:
==32150== Invalid read of size 8
==32150==    at 0xB0039C6: TiXmlNode::FirstChild(char const*) const (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB003BCD: TiXmlNode::FirstChildElement(char const*) const (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0x94F0DA4: FirstChildElement (tinyxml.h:676)
==32150==    by 0x94F0DA4: FirstChildElement (tinyxml.h:681)
==32150==    by 0x94F0DA4: AddKeyValue(TiXmlElement*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:1231)
==32150==    by 0x94FB675: InsertSDFExtensionCollision(TiXmlElement*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:1880)
==32150==    by 0x94FC379: CreateCollision(TiXmlElement*, boost::shared_ptr<urdf::Link const>, boost::shared_ptr<urdf::Collision>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:3357)
==32150==    by 0x94FC6CC: CreateCollisions(TiXmlElement*, boost::shared_ptr<urdf::Link const>) (parser_urdf.cc:3013)
==32150==    by 0x94FD2EF: CreateLink(TiXmlElement*, boost::shared_ptr<urdf::Link const>, ignition::math::Pose3<double>&) (parser_urdf.cc:2883)
==32150==    by 0x94FDC1E: CreateSDF(TiXmlElement*, boost::shared_ptr<urdf::Link const>, ignition::math::Pose3<double> const&) (parser_urdf.cc:2817)
==32150==    by 0x9505114: sdf::URDF2SDF::InitModelString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (parser_urdf.cc:3470)
==32150==    by 0x9505607: sdf::URDF2SDF::InitModelDoc(TiXmlDocument*) (parser_urdf.cc:3500)
==32150==    by 0x9505756: sdf::URDF2SDF::InitModelFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:3509)
==32150==    by 0x94E1BBB: sdf::readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<sdf::SDF>) (parser.cc:302)
==32150==  Address 0x28 is not stack'd, malloc'd or (recently) free'd
==32150== 
==32150== 
==32150== 1 errors in context 2 of 2:
==32150== Invalid read of size 8
==32150==    at 0x94FB65B: InsertSDFExtensionCollision(TiXmlElement*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:1879)
==32150==    by 0x94FC379: CreateCollision(TiXmlElement*, boost::shared_ptr<urdf::Link const>, boost::shared_ptr<urdf::Collision>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:3357)
==32150==    by 0x94FC6CC: CreateCollisions(TiXmlElement*, boost::shared_ptr<urdf::Link const>) (parser_urdf.cc:3013)
==32150==    by 0x94FD2EF: CreateLink(TiXmlElement*, boost::shared_ptr<urdf::Link const>, ignition::math::Pose3<double>&) (parser_urdf.cc:2883)
==32150==    by 0x94FDC1E: CreateSDF(TiXmlElement*, boost::shared_ptr<urdf::Link const>, ignition::math::Pose3<double> const&) (parser_urdf.cc:2817)
==32150==    by 0x9505114: sdf::URDF2SDF::InitModelString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (parser_urdf.cc:3470)
==32150==    by 0x9505607: sdf::URDF2SDF::InitModelDoc(TiXmlDocument*) (parser_urdf.cc:3500)
==32150==    by 0x9505756: sdf::URDF2SDF::InitModelFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:3509)
==32150==    by 0x94E1BBB: sdf::readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<sdf::SDF>) (parser.cc:302)
==32150==    by 0x41F8B4: ??? (in /usr/bin/gz-8.1.1)
==32150==    by 0x41DB56: ??? (in /usr/bin/gz-8.1.1)
==32150==    by 0x41AB57: ??? (in /usr/bin/gz-8.1.1)
==32150==  Address 0x3f931060 is 0 bytes inside a block of size 216 free'd
==32150==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==32150==    by 0xB003901: TiXmlNode::Clear() (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB005BD0: TiXmlElement::ClearThis() (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB005C2B: TiXmlElement::~TiXmlElement() (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB005C78: TiXmlElement::~TiXmlElement() (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB003901: TiXmlNode::Clear() (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB005BD0: TiXmlElement::ClearThis() (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB005C2B: TiXmlElement::~TiXmlElement() (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB005C78: TiXmlElement::~TiXmlElement() (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0xB003968: TiXmlNode::RemoveChild(TiXmlNode*) (in /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2)
==32150==    by 0x94FAC58: InsertSDFExtensionCollision(TiXmlElement*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:1728)
==32150==    by 0x94FC379: CreateCollision(TiXmlElement*, boost::shared_ptr<urdf::Link const>, boost::shared_ptr<urdf::Collision>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:3357)
==32150==  Block was alloc'd at
==32150==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==32150==    by 0x94FBC6E: InsertSDFExtensionCollision(TiXmlElement*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:1861)
==32150==    by 0x94FC379: CreateCollision(TiXmlElement*, boost::shared_ptr<urdf::Link const>, boost::shared_ptr<urdf::Collision>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:3357)
==32150==    by 0x94FC6CC: CreateCollisions(TiXmlElement*, boost::shared_ptr<urdf::Link const>) (parser_urdf.cc:3013)
==32150==    by 0x94FD2EF: CreateLink(TiXmlElement*, boost::shared_ptr<urdf::Link const>, ignition::math::Pose3<double>&) (parser_urdf.cc:2883)
==32150==    by 0x94FDC1E: CreateSDF(TiXmlElement*, boost::shared_ptr<urdf::Link const>, ignition::math::Pose3<double> const&) (parser_urdf.cc:2817)
==32150==    by 0x9505114: sdf::URDF2SDF::InitModelString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (parser_urdf.cc:3470)
==32150==    by 0x9505607: sdf::URDF2SDF::InitModelDoc(TiXmlDocument*) (parser_urdf.cc:3500)
==32150==    by 0x9505756: sdf::URDF2SDF::InitModelFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parser_urdf.cc:3509)
==32150==    by 0x94E1BBB: sdf::readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<sdf::SDF>) (parser.cc:302)
==32150==    by 0x41F8B4: ??? (in /usr/bin/gz-8.1.1)
==32150==    by 0x41DB56: ??? (in /usr/bin/gz-8.1.1)
==32150== 
==32150== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
osrf-migration commented 7 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I don't have time to fix this right now, but these may be some good clues about the source of the problem.