ros2 / rmw_fastrtps

Implementation of the ROS Middleware (rmw) Interface using eProsima's Fast RTPS.
Apache License 2.0
157 stars 117 forks source link

Capture `std::bad_alloc` on deserializeROSmessage. #665

Closed MiguelCompany closed 10 months ago

MiguelCompany commented 1 year ago

This should fix crashes coming from serialization mismatches that cannot be detected by Fast CDR

Related to https://github.com/ros2/ros2_documentation/issues/3288#issuecomment-1404876431

fujitatomoya commented 1 year ago

cannot get the result from server.

root@tomoyafujita:~/ros2_ws/colcon_ws# RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ros2 run demo_nodes_cpp add_two_ints_client
^C[INFO] [1674755622.413766599] [rclcpp]: signal_handler(signum=2)
[ERROR] [1674755622.414263025] [add_two_ints_client]: Interrupted while waiting for response. Exiting.

in this sample, cannot observe the core dump or crash. but it is obvious that de-serialization works unexpectedly.

root@tomoyafujita:~/ros2_ws/colcon_ws# cat DEFAULT_FASTRTPS_PROFILES.xml 
<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">

  <!-- Default publisher profile -->
  <data_writer profile_name="default publisher profile" is_default_profile="true">
    <qos>
      <data_sharing>
        <kind>AUTOMATIC</kind>
      </data_sharing>
    </qos>
    <historyMemoryPolicy>DYNAMIC</historyMemoryPolicy>
  </data_writer>

  <data_reader profile_name="default subscription profile" is_default_profile="true">
    <qos>
      <data_sharing>
        <kind>AUTOMATIC</kind>
      </data_sharing>
    </qos>
    <historyMemoryPolicy>DYNAMIC</historyMemoryPolicy>
  </data_reader>
</profiles>
root@tomoyafujita:~/ros2_ws/colcon_ws# export RMW_FASTRTPS_USE_QOS_FROM_XML=1
root@tomoyafujita:~/ros2_ws/colcon_ws# RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 run demo_nodes_cpp add_two_ints_server 
[INFO] [1674755608.560241436] [add_two_ints_server]: Incoming request
a: -2268473885457029753 b: 1
^C[INFO] [1674755623.645151231] [rclcpp]: signal_handler(signum=2)
fujitatomoya commented 1 year ago

@alsora @mauropasse if possible, would you mind trying this patch to see if it can avoid the program crash? (just sending request to the server can get the program crashed, for me that is the security issue...)

christophfroehlich commented 1 year ago

This fixes #733 if I build this branch from source in the humble container. Is there any chance that this gets merged and backported to humble?

clalancette commented 10 months ago

CI:

christophfroehlich commented 10 months ago

@clalancette would you mind backporting this to iron and humble as well? This would fix #733 then.

clalancette commented 10 months ago

@Mergifyio backport humble iron

mergify[bot] commented 10 months ago

backport humble iron

✅ Backports have been created

* [#737 Capture `std::bad_alloc` on deserializeROSmessage. (backport #665)](https://github.com/ros2/rmw_fastrtps/pull/737) has been created for branch `humble` * [#738 Capture `std::bad_alloc` on deserializeROSmessage. (backport #665)](https://github.com/ros2/rmw_fastrtps/pull/738) has been created for branch `iron`
naorwaiss commented 3 months ago

hi can i get some help i try to get topic at my ros2 iron from my jetson nano 20.04 that run ros2 foxy i get the same errror..

fujitatomoya commented 3 months ago

@naorwaiss foxy is E.O.L https://docs.ros.org/en/rolling/Releases.html#list-of-distributions, can you try ROS Iron instead of 20.04 that run ros2 foxy?

naorwaiss commented 3 months ago

um i use jetson nano so i can run ubuntu 20.04 - this mean if i understand it .. that i can install only ros2 foxy because ros2 iron is available to ubuntu 22.04..

fujitatomoya commented 3 months ago

I think that is the requirement for jetson nano platform? can you ask help for jetson community?

naorwaiss commented 3 months ago

hi the installation of humble isnt work - can help me to make the bridge between ros2 iron and foxy ?

fujitatomoya commented 3 months ago

can help me to make the bridge between ros2 iron and foxy ?

cross-distribution communication is not officially supported.