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

Service call invokes bad allocation when called from a separate docker container #2133

Closed
anastasiapan opened this issue Aug 9, 2021 · 6 comments

Comments

@anastasiapan
Copy link

I have created a service (custom) that receives a custom message and runs in a ros2 node using fast-DDS. The node is running in a docker container and every time I call the service from the same container it works fine. Whenever I call it from a different container the node crushes with std::bad_alloc.

System information

  • Hardware: Jetson nano/laptop
  • OS: Ubuntu 18.04(Jetson nano) and Ubuntu 20.04(laptop)
  • ROS2: foxy

Custom messages and service:

Service: SendPath.srv

capra_ros_path_msgs/AnnotatedPath path
---
bool success   # indicate successful run of
string message # a more verbose message (in case of error)
string uuid    # An uuid if the path was accepted

Message: AnnotatedPath.msg

std_msgs/Header header

# Longitute, Latitude, Heading
uint8 GLOBAL_POSITIONING=0
# x, y, theta
uint8 LOCAL_POSITIONING=1

# Timestamp
# <YYYY-MM-DDTHH:MM:SS>
string timestamp

# Path uuid
string path_uuid

# Map uuid
string map_uuid

# Position encoding
uint8 position_encoding 0

# Nodes
capra_ros_path_msgs/Node[] nodes

# Edges
capra_ros_path_msgs/Edge[] edges

Message: Node.msg

# uuid
string uuid

# Sequence number
uint64 sequence_number

# Position
geometry_msgs/Vector3 position

# Actions
capra_ros_path_msgs/Action[] actions

Message: Edge.msg

string uuid

# Start node
string start_node_uuid

# End node
string end_node_uuid

# Actions
capra_ros_path_msgs/Action[] actions

Container arguments:

  • Container that the server runs
    From docker-compose:
ros-path-planner:
    image: server_image
    restart: unless-stopped
    network_mode: "host"
    pid: "host"
    logging:
      driver: "json-file"
      options:
        max-file: "5"
        max-size: "20m"
    volumes:
      - /dev/shm:/dev/shm

If I call the service from within this container the message goes through and I get a response. This is how I construct the message:

ros2 service call send_path capra_ros_path_msgs/srv/SendPath "{path: {path_uuid: "path0", nodes: [{position: {x: 10.1104618, y: 56.106435899999994, z: 115.194}}, {position: {x: 10.1104106, y: 56.1064303, z: 115.145}}, {position: {x: 10.110389699999999, y: 56.106470099999996, z: 115.129}}, {position: {x: 10.110468299999999, y: 56.1064867, z: 115.256}}]}}"

I can also call it with adding the "edges" field:

ros2 service call send_path capra_ros_path_msgs/srv/SendPath "{path: {path_uuid: "path0", nodes: [{position: {x: 10.11, y: 56.10, z: 115.194}}, {position: {x: 10.11, y: 56.3, z: 115.145}}, {position: {x: 10.1, y: 56.1, z: 115.129}}, {position: {x: 10.1, y: 56.1, z: 115.2}}], edges: [{}]}}"
  • Different container
    docker run -it --rm --net host --pid host -v /dev/shm:/dev/shm my_container
    This container has my custom interfaces:
ros2 interface show capra_ros_path_msgs/srv/SendPath
capra_ros_path_msgs/AnnotatedPath path
---
bool success   # indicate successful run of
string message # a more verbose message (in case of error)
string uuid    # An uuid if the path was accepted

and I can see it in the service list:

ros2 service list
/send_path

and then I call it in the same way and I get:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

What I notice is inside build/capra_ros_path_msgs/rosidl_typesupport_fastrtps_cpp/capra_ros_path_msgs/msg/detail/dds_fastrtpsannotated_path__type_support.cpp
inside the edges field of my custom message the size is overflowed. But when I call the service from the same container it is 0 (which is correct since I do not fill that field).

@anastasiapan
Copy link
Author

@bjv-capra

@EduPonz
Copy link
Member

EduPonz commented Aug 10, 2021

I think this is the same related to #1698. Have you tried the suggestions there? I see that you were on that discussion too.

@anastasiapan
Copy link
Author

I think this is the same related to #1698. Have you tried the suggestions there? I see that you were on that discussion too.

I do not think this is related because I can communicate with the containers. I had opened it when I used a Windows host but this is not the case now. With my setup I have communication between containers - I can see and echo all of the topics and I have some simple services (for example Trigger.srv http://docs.ros.org/en/melodic/api/std_srvs/html/srv/Trigger.html) that work fine.

@pablogs9
Copy link
Member

Some questions:

  • Can you provide the server code for replicating this issue?
  • Where are the dockers running in the Ubuntu 20.04 machine or in the Jetson Nano?

Also, make sure that you have RMW_IMPLEMENTATION=rmw_fastrtps_cpp environment variable in both containers and also FASTRTPS_DEFAULT_PROFILES_FILE=PATH_TO/disable_fastdds_shm.xml where disable_fastdds_shm.xml is this file.

@anastasiapan
Copy link
Author

Hello thanks for the answers but I have made it work without passing the strings. When switching to cyclone the strings are also passed properly.

@anastasiapan
Copy link
Author

I also just noticed that there was some message type missmatch, and that may have caused the entire problem.

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

No branches or pull requests

3 participants