Gazebo crashes if a plugin parameter has an empty value

Create issue
Issue #347 closed
John Hsu created an issue

From question

...the plugin causes a segfault in gzserver as the Element::GetValueString() access the empty pointer returned by Element::GetValue(). Is there a special reason why GetValueString() and the other type specific getter functions do not return an empty string or the default constructed values if the parameter value is empty? Of course a simple workaround to circumvent the segfault would be to check if GetValue() returns a null pointer before calling GetValueString().

Comments (9)

  1. Johannes Meyer

    Yes, Element::value is null when the segfault happens. At least for the parser_deprecated no value is added to the element if the string is empty in parser_deprecated::copyBlockChildren() at parser_deprecated.cpp:103. It's probably the same with the new parser::copyChildren() method in parser.cpp:757, but in parser.cpp:766 another test is used to check if the element has a text node.

  2. Johannes Meyer

    You find a small test case attached. I just copied the hello_world plugin example from the plugin tutorials as a base.

    Until now, I have only used urdf. The sdf parser that is used in the example emits a warning if a parameter value is empty, but gazebo crashes nevertheless:

    Gazebo multi-robot simulator, version 1.0.2
    Copyright (C) 2011 Nate Koenig, John Hsu, Andrew Howard, and contributors.
    Released under the Apache 2 License.
    http://gazebosim.org
    
    Error [parser.cc:638] trying to copy stuff inside <plugin> block, but they have NULL contents
    Msg Waiting for master
    Msg Connected to gazebo master @ http://localhost:11345
    gzserver: /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr<T>::operator->() const [with T = sdf::Param]: Assertion `px != 0' failed.
    Aborted (core dumped)
    
  3. Log in to comment