Skip to content

Deserialization error when subscribing to /rosout #61

@juanrh

Description

@juanrh

Bug report

Required Info:

repositories:
  ament/ament_cmake:
    type: git
    url: https://github.com/ament/ament_cmake.git
    version: master
  ament/ament_index:
    type: git
    url: https://github.com/ament/ament_index.git
    version: master
  ament/ament_lint:
    type: git
    url: https://github.com/ament/ament_lint.git
    version: master
  ament/ament_package:
    type: git
    url: https://github.com/ament/ament_package.git
    version: master
  ament/googletest:
    type: git
    url: https://github.com/ament/googletest.git
    version: ros2
  ament/uncrustify_vendor:
    type: git
    url: https://github.com/ament/uncrustify_vendor.git
    version: master
  eProsima/Fast-CDR:
    type: git
    url: https://github.com/eProsima/Fast-CDR.git
    version: master
  eProsima/Fast-RTPS:
    type: git
    url: https://github.com/eProsima/Fast-RTPS.git
    version: master
  osrf/osrf_pycommon:
    type: git
    url: https://github.com/osrf/osrf_pycommon.git
    version: master
  osrf/osrf_testing_tools_cpp:
    type: git
    url: https://github.com/osrf/osrf_testing_tools_cpp.git
    version: master
  ros/class_loader:
    type: git
    url: https://github.com/ros/class_loader.git
    version: ros2
  ros/pluginlib:
    type: git
    url: https://github.com/ros/pluginlib.git
    version: ros2
  ros/resource_retriever:
    type: git
    url: https://github.com/ros/resource_retriever.git
    version: ros2
  ros/ros_environment:
    type: git
    url: https://github.com/ros/ros_environment.git
    version: crystal
  ros/urdfdom_headers:
    type: git
    url: https://github.com/ros/urdfdom_headers.git
    version: master
  ros-perception/laser_geometry:
    type: git
    url: https://github.com/ros-perception/laser_geometry.git
    version: ros2
  ros-planning/navigation_msgs:
    type: git
    url: https://github.com/ros-planning/navigation_msgs.git
    version: ros2
  ros-visualization/python_qt_binding:
    type: git
    url: https://github.com/ros-visualization/python_qt_binding.git
    version: crystal-devel
  ros-visualization/qt_gui_core:
    type: git
    url: https://github.com/ros-visualization/qt_gui_core.git
    version: crystal-devel
  ros-visualization/rqt:
    type: git
    url: https://github.com/ros-visualization/rqt.git
    version: crystal-devel
  ros-visualization/rqt_console:
    type: git
    url: https://github.com/ros-visualization/rqt_console.git
    version: crystal-devel
  ros-visualization/rqt_msg:
    type: git
    url: https://github.com/ros-visualization/rqt_msg.git
    version: crystal-devel
  ros-visualization/rqt_plot:
    type: git
    url: https://github.com/ros-visualization/rqt_plot.git
    version: crystal-devel
  ros-visualization/rqt_publisher:
    type: git
    url: https://github.com/ros-visualization/rqt_publisher.git
    version: crystal-devel
  ros-visualization/rqt_py_console:
    type: git
    url: https://github.com/ros-visualization/rqt_py_console.git
    version: crystal-devel
  ros-visualization/rqt_service_caller:
    type: git
    url: https://github.com/ros-visualization/rqt_service_caller.git
    version: crystal-devel
  ros-visualization/rqt_shell:
    type: git
    url: https://github.com/ros-visualization/rqt_shell.git
    version: crystal-devel
  ros-visualization/rqt_srv:
    type: git
    url: https://github.com/ros-visualization/rqt_srv.git
    version: crystal-devel
  ros-visualization/rqt_top:
    type: git
    url: https://github.com/ros-visualization/rqt_top.git
    version: crystal-devel
  ros2/ament_cmake_ros:
    type: git
    url: https://github.com/ros2/ament_cmake_ros.git
    version: master
  ros2/common_interfaces:
    type: git
    url: https://github.com/ros2/common_interfaces.git
    version: master
  ros2/console_bridge_vendor:
    type: git
    url: https://github.com/ros2/console_bridge_vendor.git
    version: master
  ros2/demos:
    type: git
    url: https://github.com/ros2/demos.git
    version: master
  ros2/examples:
    type: git
    url: https://github.com/ros2/examples.git
    version: master
  ros2/example_interfaces:
    type: git
    url: https://github.com/ros2/example_interfaces.git
    version: master
  ros2/geometry2:
    type: git
    url: https://github.com/ros2/geometry2.git
    version: ros2
  ros2/kdl_parser:
    type: git
    url: https://github.com/ros2/kdl_parser.git
    version: ros2
  ros2/launch:
    type: git
    url: https://github.com/ros2/launch.git
    version: master
  ros2/libyaml_vendor:
    type: git
    url: https://github.com/ros2/libyaml_vendor.git
    version: master
  ros2/message_filters:
    type: git
    url: https://github.com/ros2/message_filters.git
    version: master
  ros2/orocos_kinematics_dynamics:
    type: git
    url: https://github.com/ros2/orocos_kinematics_dynamics.git
    version: ros2
  ros2/poco_vendor:
    type: git
    url: https://github.com/ros2/poco_vendor.git
    version: master
  ros2/rcl_logging:
    type: git
    url: https://github.com/ros2/rcl_logging.git
    version: master
  ros2/rcl:
    type: git
    url: https://github.com/ros2/rcl.git
    version: master
  ros2/rcl_interfaces:
    type: git
    url: https://github.com/ros2/rcl_interfaces.git
    version: master
#  ros2/rclc:
#    type: git
#    url: https://github.com/ros2/rclc.git
#    version: master
  ros2/rclcpp:
    type: git
    url: https://github.com/ros2/rclcpp.git
    version: master
  ros2/rclpy:
    type: git
    url: https://github.com/ros2/rclpy.git
    version: master
  ros2/rcutils:
    type: git
    url: https://github.com/ros2/rcutils.git
    version: master
  ros2/realtime_support:
    type: git
    url: https://github.com/ros2/realtime_support.git
    version: master
  ros2/rmw:
    type: git
    url: https://github.com/ros2/rmw.git
    version: master
  ros2/rmw_connext:
    type: git
    url: https://github.com/ros2/rmw_connext.git
    version: master
  ros2/rmw_fastrtps:
    type: git
    url: https://github.com/ros2/rmw_fastrtps.git
    version: master
  ros2/rmw_implementation:
    type: git
    url: https://github.com/ros2/rmw_implementation.git
    version: master
  ros2/rmw_opensplice:
    type: git
    url: https://github.com/ros2/rmw_opensplice.git
    version: master
  ros2/robot_state_publisher:
    type: git
    url: https://github.com/ros2/robot_state_publisher.git
    version: ros2
  ros2/ros1_bridge:
    type: git
    url: https://github.com/ros2/ros1_bridge.git
    version: master
  ros2/ros2cli:
    type: git
    url: https://github.com/ros2/ros2cli.git
    version: master
  ros2/rosidl:
    type: git
    url: https://github.com/ros2/rosidl.git
    version: master
  ros2/rosidl_dds:
    type: git
    url: https://github.com/ros2/rosidl_dds.git
    version: master
  ros2/rosidl_defaults:
    type: git
    url: https://github.com/ros2/rosidl_defaults.git
    version: master
  ros2/rosidl_python:
    type: git
    url: https://github.com/ros2/rosidl_python.git
    version: master
  ros2/rosidl_typesupport:
    type: git
    url: https://github.com/ros2/rosidl_typesupport.git
    version: master
  ros2/rosidl_typesupport_connext:
    type: git
    url: https://github.com/ros2/rosidl_typesupport_connext.git
    version: master
  ros2/rosidl_typesupport_fastrtps:
    type: git
    url: https://github.com/ros2/rosidl_typesupport_fastrtps.git
    version: master
  ros2/rosidl_typesupport_opensplice:
    type: git
    url: https://github.com/ros2/rosidl_typesupport_opensplice.git
    version: master
  ros2/rviz:
    type: git
    url: https://github.com/ros2/rviz.git
    version: ros2
  ros2/sros2:
    type: git
    url: https://github.com/ros2/sros2.git
    version: master
  ros2/system_tests:
    type: git
    url: https://github.com/ros2/system_tests.git
    version: master
  ros2/tinyxml_vendor:
    type: git
    url: https://github.com/ros2/tinyxml_vendor.git
    version: master
  ros2/tinyxml2_vendor:
    type: git
    url: https://github.com/ros2/tinyxml2_vendor.git
    version: master
  ros2/tlsf:
    type: git
    url: https://github.com/ros2/tlsf.git
    version: master
#  ros2/tutorials:
#    type: git
#    url: https://github.com/ros2/tutorials.git
#    version: master
  ros2/unique_identifier_msgs:
    type: git
    url: https://github.com/ros2/unique_identifier_msgs.git
    version: master
  ros2/urdf:
    type: git
    url: https://github.com/ros2/urdf.git
    version: ros2
  ros2/urdfdom:
    type: git
    url: https://github.com/ros2/urdfdom.git
    version: ros2
  ros2/yaml_cpp_vendor:
    type: git
    url: https://github.com/ros2/yaml_cpp_vendor.git
    version: master

  • DDS implementation:

    • fastrtps
  • Client library (if applicable):

    • rclcpp

Steps to reproduce issue

mkdir -p /opt/workspace/src/ros2/
cd /opt/workspace/src/ros2/
git clone https://github.com/ros2/demos.git

apply the following diff

    diff --git a/demo_nodes_cpp/src/topics/listener.cpp b/demo_nodes_cpp/src/topics/listener.cpp
    index 056859c..a51067b 100644
    --- a/demo_nodes_cpp/src/topics/listener.cpp
    +++ b/demo_nodes_cpp/src/topics/listener.cpp
    @@ -15,10 +15,13 @@
     #include <cstdio>
     #include <memory>
     #include <string>
    +#include <stdio.h> 
     
     #include "rclcpp/rclcpp.hpp"
     #include "rcutils/cmdline_parser.h"
     
    +#include <rcl_interfaces/msg/log.hpp>
    +
     #include "std_msgs/msg/string.hpp"
     
     void print_usage()
    @@ -40,21 +43,37 @@ public:
       {
         // Create a callback function for when messages are received.
         // Variations of this function also exist using, for example UniquePtr for zero-copy transport.
    +    // auto callback =
    +    //   [this](const std_msgs::msg::String::SharedPtr msg) -> void
    +    //   {
    +    //     RCLCPP_INFO(this->get_logger(), "I heard: [%s]", msg->data.c_str());
    +    //   };
         auto callback =
    -      [this](const std_msgs::msg::String::SharedPtr msg) -> void
    +      [this](const rcl_interfaces::msg::Log::SharedPtr ros2_msg) -> void
           {
    -        RCLCPP_INFO(this->get_logger(), "I heard: [%s]", msg->data.c_str());
    +         std::cout << "I heard rcl_interfaces::msg::Log with "
    +          << "stamp=[(" << ros2_msg->stamp.sec << ", " << ros2_msg->stamp.nanosec << ")"
    +          << "], level=[" << ros2_msg->level 
    +          << "], name=[" << ros2_msg->name << "]"
    +          << "], msg=[" << ros2_msg->msg << "]"
    +          << "], file=[" << ros2_msg->file << "]"
    +          << "], function=[" << ros2_msg->function << "]"
    +          << "], line=[" << ros2_msg->line << "]"
    +          << std::endl;
    +        // RCLCPP_INFO(this->get_logger(), "I heard: [%s]", msg->data.c_str());
           };
     
         // Create a subscription to the topic which can be matched with one or more compatible ROS
         // publishers.
         // Note that not all publishers on the same topic with the same type will be compatible:
         // they must have compatible Quality of Service policies.
    -    sub_ = create_subscription<std_msgs::msg::String>(topic_name, callback);
    +    // sub_ = create_subscription<std_msgs::msg::String>(topic_name, callback);
    +    sub_ = create_subscription<rcl_interfaces::msg::Log>("/rosout", callback);
       }
     
     private:
    -  rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
    +  //rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
    +  rclcpp::Subscription<rcl_interfaces::msg::Log>::SharedPtr sub_;
     };
     
     int main(int argc, char * argv[])

then build and launch

cd /opt/workspace 
source /opt/ros2_ws/install/setup.bash 
colcon build --packages-select demo_nodes_cpp
source install/setup.bash
ros2 run demo_nodes_cpp talker & 
valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all build/demo_nodes_cpp/listener 2>&1 | tee demo_listener.log

Expected behavior

In the standard output we see messages from the talker node like [INFO] [talker]: Publishing: 'Hello World: 35', alternating with messages I heard rcl_interfaces::msg::Log with stamp=[(1548897558, 380492253)], level=... from the modified listener node, that is listening to rosout

Actual behavior

The modified listener node that is listening to rosout has realloc errors, that are reported by valgrind in demo_listener.log as follows

==8032== Memcheck, a memory error detector
==8032== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==8032== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==8032== Command: build/demo_nodes_cpp/listener
==8032== 
==8032== Invalid free() / delete / delete[] / realloc()
==8032==    at 0x4C31D2F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8032==    by 0x739DA52: rosidl_generator_c__String__assignn (in /opt/ros2_ws/build/rosidl_generator_c/librosidl_generator_c.so)
==8032==    by 0x739DAE9: rosidl_generator_c__String__assign (in /opt/ros2_ws/build/rosidl_generator_c/librosidl_generator_c.so)
==8032==    by 0xDB3D08C: __cdr_deserialize (in /opt/ros2_ws/build/rcl_interfaces/librcl_interfaces__rosidl_typesupport_fastrtps_c.so)
==8032==    by 0x93F49A6: rmw_fastrtps_cpp::TypeSupport::deserializeROSmessage(eprosima::fastcdr::Cdr&, void*) (in /opt/ros2_ws/build/rmw_fastrtps_cpp/librmw_fastrtps_cpp.so)
==8032==    by 0x9A9EAC3: rmw_fastrtps_shared_cpp::TypeSupport::deserialize(eprosima::fastrtps::rtps::SerializedPayload_t*, void*) (in /opt/ros2_ws/build/rmw_fastrtps_shared_cpp/librmw_fastrtps_shared_cpp.so)
==8032==    by 0x9E80A6F: eprosima::fastrtps::SubscriberHistory::takeNextData(void*, eprosima::fastrtps::SampleInfo_t*) (in /opt/ros2_ws/install/fastrtps/lib/libfastrtps.so.1.7.0)
==8032==    by 0x9A97FE0: rmw_fastrtps_shared_cpp::_take(char const*, rmw_subscription_t const*, void*, bool*, rmw_message_info_t*) (in /opt/ros2_ws/build/rmw_fastrtps_shared_cpp/librmw_fastrtps_shared_cpp.so)
==8032==    by 0x9A981FC: rmw_fastrtps_shared_cpp::__rmw_take_with_info(char const*, rmw_subscription_t const*, void*, bool*, rmw_message_info_t*) (in /opt/ros2_ws/build/rmw_fastrtps_shared_cpp/librmw_fastrtps_shared_cpp.so)
==8032==    by 0x93F45B9: rmw_take_with_info (in /opt/ros2_ws/build/rmw_fastrtps_cpp/librmw_fastrtps_cpp.so)
==8032==    by 0x654CD6C: rmw_take_with_info (in /opt/ros2_ws/build/rmw_implementation/librmw_implementation.so)
==8032==    by 0x55817EF: rcl_take (in /opt/ros2_ws/build/rcl/librcl.so)
==8032==  Address 0xf938530 is 48 bytes inside a block of size 168 alloc'd
==8032==    at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8032==    by 0x12B490: __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x12B18A: std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x12ACB7: std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >, (__gnu_cxx::_Lock_policy)2> >&) (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x12A88A: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >>(std::_Sp_make_shared_tag, rcl_interfaces::msg::Log_<std::allocator<void> >*, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > > const&) (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x12A4AF: std::__shared_ptr<rcl_interfaces::msg::Log_<std::allocator<void> >, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >>(std::_Sp_make_shared_tag, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > > const&) (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x129FD5: std::shared_ptr<rcl_interfaces::msg::Log_<std::allocator<void> > >::shared_ptr<std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >>(std::_Sp_make_shared_tag, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > > const&) (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x1298FE: std::shared_ptr<rcl_interfaces::msg::Log_<std::allocator<void> > > std::allocate_shared<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > >>(std::allocator<rcl_interfaces::msg::Log_<std::allocator<void> > > const&) (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x1288A0: rclcpp::message_memory_strategy::MessageMemoryStrategy<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<void> >::borrow_message() (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x12846E: rclcpp::Subscription<rcl_interfaces::msg::Log_<std::allocator<void> >, std::allocator<void> >::create_message() (in /opt/workspace/build/demo_nodes_cpp/listener)
==8032==    by 0x51ACF59: rclcpp::executor::Executor::execute_subscription(std::shared_ptr<rclcpp::SubscriptionBase>) (in /opt/ros2_ws/build/rclcpp/librclcpp.so)
==8032==    by 0x51AC9BE: rclcpp::executor::Executor::execute_any_executable(rclcpp::executor::AnyExecutable&) (in /opt/ros2_ws/build/rclcpp/librclcpp.so)
==8032== 
failed to assign string into field 'name'
I heard rcl_interfaces::msg::Log with stamp=[(1548897690, 248958130)], level=[�], name=[]], msg=[]], file=[]], function=[]], line=[0]
failed to assign string into field 'name'
I heard rcl_interfaces::msg::Log with stamp=[(1548897691, 248923210)], level=[�], name=[]], msg=[]], file=[]], function=[]], line=[0]
failed to assign string into field 'name'
I heard rcl_interfaces::msg::Log with stam

Additional information


Feature request

Feature description

Implementation considerations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions