Fix content filtering on Windows with modern Connext DDS#226
Conversation
1. Fix a bug in writer-side filtering where it assumed the built-in SQL filter returned a discontiguous sequence of cookies. Fallback to taking addresses of contiguous cookies if necessary. 2. Disable RMW_CONNEXT_BUILTIN_CFT_COMPATIBILITY_MODE on Windows for Connext 6.0+ to enable serialized evaluation and internal registration, which is required for correct filtering of ROS 2 samples. Assisted-by: Gemini CLI:2.0-Flash
…Windows Modern RTI Connext headers (6.0.0+) already provide this declaration. Re-declaring it manually causes linkage errors on MSVC. Assisted-by: Gemini CLI:2.0-Flash
RMW_CONNEXT_DDS_API_PRO_LEGACY is always defined (defaults to 0), so #if defined() was always true. Switching to #if value ensures correct skipping on modern Connext. Assisted-by: Gemini CLI:2.0-Flash
|
Pulls: #226 |
fujitatomoya
left a comment
There was a problem hiding this comment.
lgtm, @fgallegosalido can you take a look?
|
It looks good to me. I just have one question. Has the bug in the cookie handling actually happened while investigating this issue? I checked internally and that buffer is going to always be discontiguous (a buffer of pointers to Maybe, we can add a comment above that check explaining that the buffer is always going to be discontiguous. Thank you very much @mjcarroll for looking into this! |
Trying a windows run without the change to build: |
|
@sloretz I think the builds look mostly good for |
| DDS_Cookie_t ** const sql_matched_discont_buffer = | ||
| DDS_CookieSeq_get_discontiguous_buffer(sql_matched); | ||
| memcpy( | ||
| &(writer_data->matched_readers_buffer[matched_readers_start]), | ||
| sql_matched_buffer, | ||
| sizeof(DDS_Cookie_t *) * sql_matched_len); | ||
| if (nullptr != sql_matched_discont_buffer) { | ||
| memcpy( | ||
| &(writer_data->matched_readers_buffer[matched_readers_start]), | ||
| sql_matched_discont_buffer, | ||
| sizeof(DDS_Cookie_t *) * sql_matched_len); | ||
| } else { | ||
| DDS_Cookie_t * const sql_matched_cont_buffer = | ||
| DDS_CookieSeq_get_contiguous_buffer(sql_matched); | ||
| for (size_t i = 0; i < sql_matched_len; ++i) { | ||
| writer_data->matched_readers_buffer[matched_readers_start + i] = | ||
| &sql_matched_cont_buffer[i]; | ||
| } | ||
| } |
There was a problem hiding this comment.
| DDS_Cookie_t ** const sql_matched_discont_buffer = | |
| DDS_CookieSeq_get_discontiguous_buffer(sql_matched); | |
| memcpy( | |
| &(writer_data->matched_readers_buffer[matched_readers_start]), | |
| sql_matched_buffer, | |
| sizeof(DDS_Cookie_t *) * sql_matched_len); | |
| if (nullptr != sql_matched_discont_buffer) { | |
| memcpy( | |
| &(writer_data->matched_readers_buffer[matched_readers_start]), | |
| sql_matched_discont_buffer, | |
| sizeof(DDS_Cookie_t *) * sql_matched_len); | |
| } else { | |
| DDS_Cookie_t * const sql_matched_cont_buffer = | |
| DDS_CookieSeq_get_contiguous_buffer(sql_matched); | |
| for (size_t i = 0; i < sql_matched_len; ++i) { | |
| writer_data->matched_readers_buffer[matched_readers_start + i] = | |
| &sql_matched_cont_buffer[i]; | |
| } | |
| } | |
| DDS_Cookie_t ** const sql_matched_buffer = | |
| DDS_CookieSeq_get_discontiguous_buffer(sql_matched); | |
| RMW_CONNEXT_ASSERT(nullptr != sql_matched_buffer) | |
| memcpy( | |
| &(writer_data->matched_readers_buffer[matched_readers_start]), | |
| sql_matched_buffer, | |
| sizeof(DDS_Cookie_t *) * sql_matched_len); |
|
Interesting new test failures, but all the content filtering test failures are gone. I'm going to apply the above suggestion and start full CI. |
72121ba to
561d4b4
Compare
Signed-off-by: Shane Loretz <sloretz@intrinsic.ai>
|
Pulls: #226 |
|
I think I see all the test failures in the latest nightlies, so I'm going to merge this. |
|
@Mergifyio backport lyrical |
✅ Backports have been createdDetails
|
* Fix content filtering on Windows with Connext 7 1. Fix a bug in writer-side filtering where it assumed the built-in SQL filter returned a discontiguous sequence of cookies. Fallback to taking addresses of contiguous cookies if necessary. 2. Disable RMW_CONNEXT_BUILTIN_CFT_COMPATIBILITY_MODE on Windows for Connext 6.0+ to enable serialized evaluation and internal registration, which is required for correct filtering of ROS 2 samples. Assisted-by: Gemini CLI:2.0-Flash * Fix redefinition of DDS_DomainParticipant_register_contentfilterI on Windows Modern RTI Connext headers (6.0.0+) already provide this declaration. Re-declaring it manually causes linkage errors on MSVC. Assisted-by: Gemini CLI:2.0-Flash * Fix incorrect preprocessor check for legacy Connext API RMW_CONNEXT_DDS_API_PRO_LEGACY is always defined (defaults to 0), so #if defined() was always true. Switching to #if value ensures correct skipping on modern Connext. Assisted-by: Gemini CLI:2.0-Flash * Apply @fgallegosalido suggestion to assert discontiguous buffer --------- (cherry picked from commit 9e3beb8) Signed-off-by: Shane Loretz <sloretz@intrinsic.ai> Co-authored-by: Michael Carroll <carroll.michael@gmail.com> Co-authored-by: Shane Loretz <sloretz@intrinsic.ai>
Description
This PR fixes Content Filtering on Windows when using modern versions of RTI Connext DDS (6.x and 7.x).
The Problem
Previously, the
rmw_connextddsimplementation on Windows was forced into a "Compatibility Mode." This mode:This led to failures in
rcl,rclcpp, andrcl_actiontests where samples were received by subscribers despite being explicitly filtered out by SQL expressions.The Fix
CMakeLists.txtto only enableRMW_CONNEXT_BUILTIN_CFT_COMPATIBILITY_MODEon Windows for Connext versions older than 6.0.0. For modern versions, we now use the internalregister_contentfilterIAPI, which supports evaluation on CDR-serialized samples.custom_sql_filter.hppto use the official RTI declaration ofregister_contentfilterI(available in modern headers) to avoid linkage errors on MSVC.RTI_CustomSqlFilter_writer_evaluated_resultwhere it assumed RTI's built-in filter always returned a discontiguous sequence of cookies. It now correctly handles both contiguous and discontiguous sequences.Verification
Verified on Windows using a targeted CI run with Connext 7.7.0. All content filtering tests in
rcl,rclcpp, andrcl_actionpassed.CI Result (Windows 10, Connext 7.7.0): https://ci.ros2.org/job/ci_windows/27743/
Is this user-facing behavior change?
No, it fixes a regression in existing functionality.
Did you use Generative AI?
Yes. Gemini CLI:2.0-Flash [web_fetch, run_shell_command, replace, git, gh]