Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::bad_alloc crash in robot_description_callback #1986

Open
tonynajjar opened this issue Jan 7, 2025 · 7 comments
Open

std::bad_alloc crash in robot_description_callback #1986

tonynajjar opened this issue Jan 7, 2025 · 7 comments
Labels

Comments

@tonynajjar
Copy link
Contributor

Describe the bug

@saikishor I localized that after this commit I get the following crash.
I don't really see the relation though, do you?

Screenshots

[gazebo-1] [INFO] [1736265253.392840323] [gz_ros_control]: Loading controller_manager
[gazebo-1] [INFO] [1736265253.404793628] [controller_manager]: Subscribing to '/robot_description' topic for robot description.
[gazebo-1] [WARN] [1736265253.404938458] [gz_ros_control]: Waiting RM to load and initialize hardware...
[gazebo-1] [INFO] [1736265253.406613475] [controller_manager]: Received robot description from topic.
[gazebo-1] terminate called after throwing an instance of 'std::bad_alloc'
[gazebo-1]   what():  std::bad_alloc
[gazebo-1] Stack trace (most recent call last) in thread 584229:
[gazebo-1] #21   Object "[0xffffffffffffffff]", at 0xffffffffffffffff, in 
[gazebo-1] #20   Object "/usr/lib/x86_64-linux-gnu/libc.so.6", at 0x7ebd568a0c3b, in 
[gazebo-1] #19   Object "/usr/lib/x86_64-linux-gnu/libc.so.6", at 0x7ebd56813a93, in 
[gazebo-1] #18   Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7ebd5186edb3, in 
[gazebo-1] #17   Object "/opt/ros/jazzy/lib/librclcpp.so", at 0x7ebd1a0c0dc6, in rclcpp::executors::MultiThreadedExecutor::run(unsigned long)
[gazebo-1] #16   Object "/opt/ros/jazzy/lib/librclcpp.so", at 0x7ebd1a0afc29, in rclcpp::Executor::execute_any_executable(rclcpp::AnyExecutable&)
[gazebo-1] #15   Object "/opt/ros/jazzy/lib/librclcpp.so", at 0x7ebd1a0af4fa, in rclcpp::Executor::execute_subscription(std::shared_ptr<rclcpp::SubscriptionBase>)
[gazebo-1] #14   Object "/home/angsa/underlay_ws/install/controller_manager/lib/libcontroller_manager.so", at 0x7ebd1a4193ef, in rclcpp::Subscription<std_msgs::msg::String_<std::allocator<void> >, std::allocator<void>, std_msgs::msg::String_<std::allocator<void> >, std_msgs::msg::String_<std::allocator<void> >, rclcpp::message_memory_strategy::MessageMemoryStrategy<std_msgs::msg::String_<std::allocator<void> >, std::allocator<void> > >::handle_message(std::shared_ptr<void>&, rclcpp::MessageInfo const&)
[gazebo-1] #13   Object "/home/angsa/underlay_ws/install/controller_manager/lib/libcontroller_manager.so", at 0x7ebd1a35516d, in std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<std::__detail::__variant::__deduce_visit_result<void> (*)(rclcpp::AnySubscriptionCallback<std_msgs::msg::String_<std::allocator<void> >, std::allocator<void> >::dispatch<std_msgs::msg::String_<std::allocator<void> > >(std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > >, rclcpp::MessageInfo const&)::{lambda(auto:1&&)#1}&&, std::variant<std::function<void (std_msgs::msg::String_<std::allocator<void> > const&)>, std::function<void (std_msgs::msg::String_<std::allocator<void> > const&, rclcpp::MessageInfo const&)>, std::function<void (rclcpp::SerializedMessage const&)>, std::function<void (rclcpp::SerializedMessage const&, rclcpp::MessageInfo const&)>, std::function<void (std::unique_ptr<std_msgs::msg::String_<std::allocator<void> >, std::default_delete<std_msgs::msg::String_<std::allocator<void> > > >)>, std::function<void (std::unique_ptr<std_msgs::msg::String_<std::allocator<void> >, std::default_delete<std_msgs::msg::String_<std::allocator<void> > > >, rclcpp::MessageInfo const&)>, std::function<void (std::unique_ptr<rclcpp::SerializedMessage, std::default_delete<rclcpp::SerializedMessage> >)>, std::function<void (std::unique_ptr<rclcpp::SerializedMessage, std::default_delete<rclcpp::SerializedMessage> >, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > const>)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > const>, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage const>)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage const>, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > const> const&)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > const> const&, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage const> const&)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage const> const&, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > >)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > >, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage>)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage>, rclcpp::MessageInfo const&)> >&)>, std::integer_sequence<unsigned long, 0ul> >::__visit_invoke(rclcpp::AnySubscriptionCallback<std_msgs::msg::String_<std::allocator<void> >, std::allocator<void> >::dispatch<std_msgs::msg::String_<std::allocator<void> > >(std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > >, rclcpp::MessageInfo const&)::{lambda(auto:1&&)#1}&&, std::variant<std::function<void (std_msgs::msg::String_<std::allocator<void> > const&)>, std::function<void (std_msgs::msg::String_<std::allocator<void> > const&, rclcpp::MessageInfo const&)>, std::function<void (rclcpp::SerializedMessage const&)>, std::function<void (rclcpp::SerializedMessage const&, rclcpp::MessageInfo const&)>, std::function<void (std::unique_ptr<std_msgs::msg::String_<std::allocator<void> >, std::default_delete<std_msgs::msg::String_<std::allocator<void> > > >)>, std::function<void (std::unique_ptr<std_msgs::msg::String_<std::allocator<void> >, std::default_delete<std_msgs::msg::String_<std::allocator<void> > > >, rclcpp::MessageInfo const&)>, std::function<void (std::unique_ptr<rclcpp::SerializedMessage, std::default_delete<rclcpp::SerializedMessage> >)>, std::function<void (std::unique_ptr<rclcpp::SerializedMessage, std::default_delete<rclcpp::SerializedMessage> >, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > const>)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > const>, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage const>)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage const>, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > const> const&)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > const> const&, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage const> const&)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage const> const&, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > >)>, std::function<void (std::shared_ptr<std_msgs::msg::String_<std::allocator<void> > >, rclcpp::MessageInfo const&)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage>)>, std::function<void (std::shared_ptr<rclcpp::SerializedMessage>, rclcpp::MessageInfo const&)> >&)
[gazebo-1] #12   Object "/home/angsa/underlay_ws/install/controller_manager/lib/libcontroller_manager.so", at 0x7ebd1a34f993, in std::_Function_handler<void (std_msgs::msg::String_<std::allocator<void> > const&), std::_Bind<void (controller_manager::ControllerManager::*(controller_manager::ControllerManager*, std::_Placeholder<1>))(std_msgs::msg::String_<std::allocator<void> > const&)> >::_M_invoke(std::_Any_data const&, std_msgs::msg::String_<std::allocator<void> > const&)
[gazebo-1] #11   Object "/home/angsa/underlay_ws/install/controller_manager/lib/libcontroller_manager.so", at 0x7ebd1a34d092, in controller_manager::ControllerManager::robot_description_callback(std_msgs::msg::String_<std::allocator<void> > const&)
[gazebo-1] #10   Object "/home/angsa/underlay_ws/install/controller_manager/lib/libcontroller_manager.so", at 0x7ebd1a34c5a6, in controller_manager::ControllerManager::init_resource_manager(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[gazebo-1] #9    Object "/opt/ros/jazzy/lib/libgz_ros2_control-system.so", at 0x7ebd3ccd42a6, in 
[gazebo-1] #8    Object "/opt/ros/jazzy/lib/libgz_ros2_control-system.so", at 0x7ebd3ccf8aca, in 
[gazebo-1] #7    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7ebd51827ac7, in 
[gazebo-1] #6    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7ebd5183d390, in __cxa_throw
[gazebo-1] #5    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7ebd51827a54, in std::terminate()
[gazebo-1] #4    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7ebd5183d0d9, in 
[gazebo-1] #3    Object "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7ebd51827ff4, in 
[gazebo-1] #2    Object "/usr/lib/x86_64-linux-gnu/libc.so.6", at 0x7ebd5679f8fe, in abort
[gazebo-1] #1    Object "/usr/lib/x86_64-linux-gnu/libc.so.6", at 0x7ebd567bc26d, in gsignal
[gazebo-1] #0    Object "/usr/lib/x86_64-linux-gnu/libc.so.6", at 0x7ebd56815b1c, in pthread_kill
[gazebo-1] Aborted (Signal sent by tkill() 583990 1000)
[INFO] [gazebo-1]: process has finished cleanly [pid 583899]

Environment (please complete the following information):

  • OS: Ubuntu Noble
  • Version: Jazzy
  • ros2_control built from source

Additional context
Add any other context about the problem here, especially include any modifications to ros2_control that relate to this issue.

@tonynajjar tonynajjar added the bug label Jan 7, 2025
@saikishor
Copy link
Member

Hello @tonynajjar,

Thank you for reporting it. Can you please share the ros2_control tag information inside your URDF?. I'm not sure if this is coming from the recent commit, as we have tests internally that are working. I would suggest to remove the installed hardware_interface package to just discard some binary incompatibility.

Thank you

@tonynajjar
Copy link
Contributor Author

  <ros2_control name="GazeboSimSystem" type="system">
    <hardware>
      <plugin>gz_ros2_control/GazeboSimSystem</plugin>
    </hardware>
    <joint name="wheel_left_joint">
      <command_interface name="velocity">
        <param name="min">-1</param>
        <param name="max">1</param>
      </command_interface>
      <state_interface name="position"/>
      <state_interface name="velocity"/>
    </joint>
    <joint name="wheel_right_joint">
      <command_interface name="velocity">
        <param name="min">-1</param>
        <param name="max">1</param>
      </command_interface>
      <state_interface name="position"/>
      <state_interface name="velocity"/>
    </joint>
  </ros2_control>

  <gazebo>
    <plugin filename="gz_ros2_control-system" name="gz_ros2_control::GazeboSimROS2ControlPlugin">
      <ros>
        <remapping>~/cmd_vel:=/cmd_vel</remapping>
        <remapping>~/odom:=/odometry/encoders</remapping>
      </ros>
      <parameters>path_to_yaml</parameters>
    </plugin>
  </gazebo>
</robot>

I will check if it works with the binaries without having anything in source

@saikishor
Copy link
Member

The above one should work AFAIK. Can you check source only without any binaries of hardware_interface?

[gazebo-1] #9 Object "/opt/ros/jazzy/lib/libgz_ros2_control-system.so", at 0x7ebd3ccd42a6, in

Looking at your log, I see that the gz_ros2_control is being used from the binaries. Remember that it is linking againsyt installed binary instead of your local one. Try also compiling this locally

@tonynajjar
Copy link
Contributor Author

When building gz_ros2_control from source I get:

📦 angsa@tony-XMG-CORE-M24:~/underlay_ws/src$ colcon build --packages-up-to gz_ros2_control
Starting >>> launch_ros
Starting >>> ros2_control_test_assets
Starting >>> controller_manager_msgs
Finished <<< ros2_control_test_assets [0.33s]                                                                                          
Finished <<< controller_manager_msgs [0.79s]                                                      
Finished <<< launch_ros [1.36s]           
Starting >>> joint_limits
Starting >>> launch_testing_ros
Finished <<< joint_limits [0.33s]                                                              
Starting >>> hardware_interface
Finished <<< hardware_interface [0.31s]                                                             
Starting >>> controller_interface
Starting >>> hardware_interface_testing                                                     
Finished <<< hardware_interface_testing [0.25s]                                                                                                     
Finished <<< controller_interface [0.30s]
Finished <<< launch_testing_ros [1.30s]           
Starting >>> controller_manager
--- stderr: controller_manager                               
/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
---
Finished <<< controller_manager [0.75s]
Starting >>> gz_ros2_control
--- stderr: gz_ros2_control                               
In file included from /opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/serialized.pb.h:12,
                 from /opt/ros/jazzy/opt/gz_sim_vendor/include/gz/sim8/gz/sim/EntityComponentManager.hh:20,
                 from /opt/ros/jazzy/opt/gz_sim_vendor/include/gz/sim8/gz/sim/System.hh:24,
                 from /home/angsa/underlay_ws/src/gz_ros2_control/gz_ros2_control/include/gz_ros2_control/gz_system_interface.hpp:24,
                 from /home/angsa/underlay_ws/src/gz_ros2_control/gz_ros2_control/include/gz_ros2_control/gz_system.hpp:24,
                 from /home/angsa/underlay_ws/src/gz_ros2_control/gz_ros2_control/src/gz_system.cpp:15:
/opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/details/serialized.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
   17 | #error This file was generated by an older version of protoc which is
      |  ^~~~~
/opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/details/serialized.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
   18 | #error incompatible with your Protocol Buffer headers. Please
      |  ^~~~~
/opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/details/serialized.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
   19 | #error regenerate this file with a newer version of protoc.
      |  ^~~~~
In file included from /opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/double_v.pb.h:12,
                 from /opt/ros/jazzy/opt/gz_sim_vendor/include/gz/sim8/gz/sim/components/Serialization.hh:31,
                 from /opt/ros/jazzy/opt/gz_sim_vendor/include/gz/sim8/gz/sim/components/Name.hh:23,
                 from /home/angsa/underlay_ws/src/gz_ros2_control/gz_ros2_control/src/gz_ros2_control_plugin.cpp:28:
/opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/details/double_v.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
   17 | #error This file was generated by an older version of protoc which is
      |  ^~~~~
/opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/details/double_v.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
   18 | #error incompatible with your Protocol Buffer headers. Please
      |  ^~~~~
/opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/details/double_v.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
   19 | #error regenerate this file with a newer version of protoc.
      |  ^~~~~
In file included from /opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/actor.pb.h:12,
                 from /opt/ros/jazzy/opt/gz_sim_vendor/include/gz/sim8/gz/sim/Conversions.hh:20,
                 from /opt/ros/jazzy/opt/gz_sim_vendor/include/gz/sim8/gz/sim/components/Serialization.hh:37:
/opt/ros/jazzy/opt/gz_msgs_vendor/include/gz/msgs10/gz/msgs/details/actor.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
   17 | #error This file was generated by an older version of protoc which is
...

I guess I would also need to build gz_msgs_vendor/gz_msgs from source which doesn't seem so simple (or at least I don't know how because it's vendored). Do you know a way?

This is the installed version:

ros-jazzy-gz-msgs-vendor is already the newest version (0.0.5-1noble.20241218.083446).

@saikishor
Copy link
Member

@tonynajjar are you using the jazzy branch?. If so, try with the last tag and see if it works

@tonynajjar
Copy link
Contributor Author

sorry forgot to mention, yes I'm using the jazzy branch. I don't want to take too much of your time on what I believe is like you say, an issue with my setup e.g binary mismatch. I will try a bit more and if I can't get it to work I'll just pin my fork to before that problematic commit.

@saikishor
Copy link
Member

Sure. No worries. Thank you. Keep us posted :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants