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

[Bug] ROS 2 node crashes while querying admin space #13

Open
evshary opened this issue Oct 17, 2023 · 2 comments
Open

[Bug] ROS 2 node crashes while querying admin space #13

evshary opened this issue Oct 17, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@evshary
Copy link

evshary commented Oct 17, 2023

Describe the bug

While running ROS 2 node, using curl to query admin space will cause the node to crash.

To reproduce

  1. In terminal 1, run talker
ros2 run demo_nodes_cpp talker
  1. In terminal 2, run zenoh-bridge-ros2dds
./target/release/zenoh-bridge-ros2dds --rest-http-port 8000
  1. Query the admin space
curl http://127.0.0.1:8000/\*\*
  1. terminal 1 will crash
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

System info

Platform: Ubuntu 22.04
ROS version: Humble
Bridge version: main branch

@evshary evshary added the bug Something isn't working label Oct 17, 2023
@JEnoch
Copy link
Member

JEnoch commented Nov 20, 2023

curl http://127.0.0.1:8000/\*\*

Such a key expression (**) doesn't query only the admin space, but ALL Zenoh key space, that includes both user space and admin space.
Therefore, ALL the queryables declared by the bridge are queried, including the ones mapping to ROS 2 Services and Actions. But as your query has not body payload, the ROS 2 Service (probably related to ROS parameters in your case) fails to deserialize the payload and crashes.

In general, it's not a good idea to query on ** as it could trigger some queryables that have some expectation wrt. the query.
The zenoh-bridge-ros2dds admin space is on @ros2/**. You should query it as such:

curl http://127.0.0.1:8000/@ros2/\*\*

In the bridge, I will add a safety check in queryables for Services and Action avoiding to forward to ROS an empty request.
That would at least prevent crashes by accident of a query without payload.
Still, nothing can prevent a malformed payload to make a ROS Node to crash, except defensive code inside ROS itself.

@evshary
Copy link
Author

evshary commented Nov 20, 2023

That makes sense. I also found this by accident.
We indeed can't prevent wrong requests to ROS Node and crash it.
It's fine for me to at least add the safety check on empty requests, since users might run this mistakenly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants