-
Notifications
You must be signed in to change notification settings - Fork 33
Conversation
88b6595
to
321cfcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm except for one comment about hardcoded values
rmw_connext_shared_cpp/src/node.cpp
Outdated
RMW_SET_ERROR_MSG("failed to resize participant user_data"); | ||
return NULL; | ||
} | ||
const char * prefix = "name="; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would reduce the number of hardcoded values if we defined this prefix above and use it's length everywhere below (rather than hardcoding 5
s and 6
s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 221769e.
if (!name || dds_ret != DDS_RETCODE_OK) { | ||
name = "(no name)"; | ||
std::string name; | ||
if (dds_ret == DDS_RETCODE_OK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: enums and litterals on left side of operators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 1164cea.
93e4877
to
1164cea
Compare
rmw_connext_shared_cpp/src/node.cpp
Outdated
@@ -53,6 +53,23 @@ create_node( | |||
// This String_dup is not matched with a String_free because DDS appears to | |||
// free this automatically. | |||
participant_qos.participant_name.name = DDS::String_dup(name); | |||
// since the participant name is not part of the DDS spec | |||
// the node name is also set in the user_data | |||
DDS_Long name_length = strlen(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generates a warning on Windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
e523a82
to
c800708
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you testing this with opensplice 6.7 or a different version? When I tested the behaviour with ros2 node list
cross-vendor (to verify ros2/ros2cli#72 is resolved), it didn't work. A connext daemon will detect an opensplice talker
node now, but still has issues with whatever other participants opensplice spawns.
} | ||
if (name.empty()) { | ||
// use participant name if no name was found in the user data | ||
name = pbtd.participant_name.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The participant name might be null (that seems to be the case for whatever additional participants opensplice is spawning). If we just store the participant name without checking, this causes a segfault at the if (name.empty())
check on the std::string
below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. While the participant name is a std::string
in other implementations it is a char *
in Connext. I checked for NULL
in ae30090 before assigning it to a std::string
.
if (name.empty()) { | ||
// ignore discovered participants without a name | ||
node_names->data[i] = nullptr; | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think continue
ing here is a good idea, higher layers are probably assuming that the node_names
map will return valid strings (nothing in the rcl_get_node_names
documentation suggests otherwise). FWICT rclpy
, for example, is assuming null-terminated strings are stored at each index: https://github.com/ros2/rclpy/blob/fbd80a27342d56b32047ecb7f2ad2e44e9d027b3/rclpy/src/rclpy/_rclpy.c#L2323
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line you refenced should be fine if NULL
is passed in as far as I understand the API docs:
If u is NULL, this function behaves like PyUnicode_FromUnicode() with the buffer set to NULL. This usage is deprecated in favor of PyUnicode_New().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're referencing the documentation for PyUnicode_FromStringAndSize
, PyUnicode_FromString
says:
Create a Unicode object from a UTF-8 encoded null-terminated char buffer u.
The error (when it doesn't segfault) is: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I stopped at the first match and didn't check the exact function name 😞
c800708
to
ae30090
Compare
Yes, with 6.7.
Can you describe what exact issues you are seeing. Maybe with a sequence of commands you are running in order to reproduce it. |
The specific issue is the segfault that I mentioned in the inline comments. The sequence is the same as in the initial issue:
|
What output are you seeing/how are you testing the cross-vendor behaviour? Does |
I was able to reproduce the problem with the OpenSplice talker and the Connext node list. I created PRs to document the behavior of the rcl API as well as fix the usage in rclcpp and rclpy. Two considered alternatives:
|
ae30090
to
74e28fb
Compare
Connect to ros2/ros2#438.