v-kiniv / rws

WebSocket gateway for ROS2 topics and services
Apache License 2.0
10 stars 7 forks source link

Custom service crash when deserializing request #27

Open martinfri opened 5 months ago

martinfri commented 5 months ago

It seems like I got a similar issue to #12 which i try to wrap my head around. My custom service looks as followed

a topic type called Stream with the following content

uint8 type
string name
string source
uint32 x
uint32 y
uint32[] rate

The service using the topic set Stream

foo_msgs/Stream stream
---
bool ok

Crashes here

Could it be the allocate_message call, when it got one member which contain members with strings?

v-kiniv commented 5 months ago

Thanks for the report. Yeah the problem is in the allocate_message, it does not take into account nested messages with strings. I created PR https://github.com/v-kiniv/rws/pull/28 with a fix, please let me know if it's working for you. It doesn't cover the case where nested message with string is an array(foo_msgs/Stream[] stream), I'll address it in a separate PR when I come up with a solution for that.

martinfri commented 5 months ago

Perfect, I have tested the PR, and it does indeed fix the issue. Ah, the cast to auto sub_members = static_cast<const MessageMembers *>(member->members_->data); did the trick!

Regarding the array case, would probably be nice to have, but currently i have no such case.

v-kiniv commented 5 months ago

Great, thanks for testing the PR, I'll merge it then. As for the issue, I'm leaving it open till array case is fixed.