Gazebo | Ignition | Community
Ask Your Question
0

stack smashing detected combining ROS2 node an gzclient [closed]

asked 2018-04-10 10:54:28 -0500

JesperSmith gravatar image

Hi,

I'm trying to create a simple node that listens to Gazebo transport messages and republishes them on ROS2.

When I try to run the client/node I get the following error (Backtrace at the end of the message)

*** stack smashing detected ***: <unknown> terminated

The reason I suspect Gazebo is that the stack smash only happens when I actually start the gz server. Also, while the backtrace points at the FastRTPS XML loading code, if I spin the ROS node and then start the gz server, it will crash after I start the server.

I've created the following stub code to test. If you remove the allocation of std::shared_ptr<gazeborealsensebridge> bridge it will not crash. This code will only crash if the gzserver is running.

#include <iostream>
#include <memory>

#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/point_cloud2.hpp>

#include <gazebo/transport/transport.hh>
#include <gazebo/msgs/msgs.hh>

#include <gazebo/gazebo_client.hh>

class GazeboRealSenseBridge : public rclcpp::Node
{
public:
    GazeboRealSenseBridge() : rclcpp::Node("gazebo_realsense_bridge")
    {
        publisher = this->create_publisher<sensor_msgs::msg::PointCloud2>("realsense_pointcloud");



    }

private:
    rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr publisher;


};

int main(int argc, char **argv)
{
    rclcpp::init(argc, argv);
    gazebo::client::setup(0, nullptr);


    std::shared_ptr<GazeboRealSenseBridge> bridge = std::make_shared<GazeboRealSenseBridge>();

    std::map<std::string, std::list<std::string> > messageTypesAndTopics = gazebo::transport::getAdvertisedTopics();
    for(auto it = messageTypesAndTopics.begin(); it != messageTypesAndTopics.end(); it++)
    {
        for(auto topicIt = it->second.begin(); topicIt != it->second.end(); topicIt++)
        {
            std::cout << *topicIt << " (" << it->first << ")" << std::endl;
        }
    }



    gazebo::client::shutdown();
//    rclcpp::spin(bridge);
    rclcpp::shutdown();
    return 0;
}

Appendix - Backtrace

I think this backtrace is suspect, as it will show the same backtrace if you spin the ros node and start the server later. This code should not continuously run.

Thread 1 "gazebo-realsens" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6178f5d in __GI_abort () at abort.c:90
#2  0x00007ffff61c128d in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff62e6a26 "*** %s
***: %s terminated\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff6267811 in __GI___fortify_fail_abort (need_backtrace=need_backtrace@entry=false, msg=msg@entry=0x7ffff62e6a0e "stack smashing detected") at fortify_fail.c:33
#4  0x00007ffff62677d2 in __stack_chk_fail () at stack_chk_fail.c:29
#5  0x00007ffff38b4031 in eprosima::fastrtps::xmlparser::XMLParser::loadXML (filename=<error reading variable: Cannot create a lazy string with address 0x0, and a non-zero length.>, Python Exception <class 'TypeError'> expected string or bytes-like object:  root=) at /home/rosbuild/ci_scripts/ws/src/eProsima/Fast-RTPS/src/cpp/xmlparser/XMLParser.cpp:228
#6  0x00007ffff38be3fc in eprosima::fastrtps::xmlparser::XMLProfileManager::loadXMLFile (filename=<error reading variable: Cannot create a lazy string with address 0x0, and a non-zero length.>) at /home/rosbuild/ci_scripts/ws/src/eProsima/Fast-RTPS/src/cpp/xmlparser/XMLProfileManager.cpp:105
#7  0x00007ffff38bee68 in eprosima::fastrtps::xmlparser::XMLProfileManager::loadDefaultXMLFile () at /home/rosbuild/ci_scripts/ws/src/eProsima/Fast-RTPS/src/cpp/xmlparser/XMLProfileManager.cpp:86
#8  0x00007ffff3814fcb in eprosima ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by JesperSmith
close date 2018-04-11 02:32:14.312652

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-04-11 02:31:55 -0500

JesperSmith gravatar image

My bad. Recompiling ROS2 from source fixed the issue.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-04-10 10:50:03 -0500

Seen: 1,108 times

Last updated: Apr 11 '18