Skip to content

fix: rmw-zenoh-rs based on rclcpp test#109

Open
YuanYuYuan wants to merge 4 commits intomainfrom
dev/rclcpp
Open

fix: rmw-zenoh-rs based on rclcpp test#109
YuanYuYuan wants to merge 4 commits intomainfrom
dev/rclcpp

Conversation

@YuanYuYuan
Copy link
Collaborator

No description provided.

@YuanYuYuan YuanYuYuan changed the title fix: rmw-zenoh-rs from rclcpp test fix: rmw-zenoh-rs based on rclcpp test Feb 24, 2026
Three related fixes to rmw_wait and the notifier:

1. Notifier::notify_all() now holds the mutex before calling cv.notify_all().
   This closes the lost-wakeup race: a notification fired between check_ready()
   and wait_for() would previously be silently dropped.

2. WaitSetImpl::wait() switches from duration-based to deadline-based waiting.
   The absolute deadline is computed once at entry; each loop iteration uses
   the remaining time. This prevents spurious wakeups from extending the total
   wait beyond the requested timeout.

3. rmw_wait() now NULLs out all entity arrays on RMW_RET_TIMEOUT.

   The RMW contract requires that entries which are not ready be set to NULL.
   Previously the TIMEOUT path returned without touching the arrays, leaving
   stale non-NULL pointers in place. rcl/wait.c reads these back
   unconditionally (is_ready = guard_conditions[i] != NULL), so rcl would
   see every guard condition as "triggered". When rcl then returned
   RCL_RET_OK because a timer had fired, ThreadSafeSynchronization::sync_wait
   interpreted the stale interrupt guard condition pointer as an internal
   class interrupt (was_interrupted_by_this_class=true) and looped forever
   instead of returning WaitResultKind::Ready — causing all timer-based
   tests to time out.

Fixes: test_thread_safe_synchronization/wait_timer,
       test_executors/StaticSingleThreadedExecutor.spinWithTimer,
       test_executors/StaticSingleThreadedExecutor.spinWhileAlreadySpinning,
       test_executor/spin_all_fail_wait_set_clear,
       test_dynamic_storage, test_static_storage, test_logger_service
The rmw_event_type_to_zenoh_event() mapping assumed RMW_EVENT_INVALID=0
at the start of the enum, but rmw/event.h starts with
RMW_EVENT_LIVELINESS_CHANGED=0 and RMW_EVENT_INVALID=11 is the sentinel
at the end. This caused every event type to be mapped to the wrong
ZenohEventType, preventing QoS incompatibility callbacks and other
event-driven features from working.

Fixes test_events_executor/test_default_incompatible_qos_callbacks and
improves rclcpp test pass rate from 755/781 to 765/791.
…counts

GraphEventManager.trigger_graph_change was broadcasting matched events
to ALL registered entities regardless of topic, causing double-counting
and negative current_count values. Additionally, remove_local_entity
and the liveliness DELETE callback both fired trigger_graph_change,
producing duplicate events.

Changes:
- Store topic per entity in GraphEventManager for topic-based filtering
- Filter trigger_graph_change to only notify entities on the same topic
- Remove duplicate trigger_graph_change from remove_local_entity
  (liveliness DELETE callback already handles it)
- Clamp current_count to >= 0 in EventsManager::update_event_status
- Use .max(0) when casting i32 -> usize in rmw_take_event to prevent
  negative values becoming u64::MAX
- Add input validation to all RMW graph functions:
  - Node name/namespace validation via rmw_validate_node_name/namespace
  - Topic/service name validation via rmw_validate_full_topic_name
  - Allocator validation via rcutils_allocator_is_valid
  - Pre-initialized array checks (rmw_names_and_types_check_zero, etc.)
- Replace HashMap with BTreeMap in graph API for deterministic ordering
- Fix serialization buffer: truncate to actual CDR size instead of
  sending the full pre-allocated buffer (was always >=512 bytes)
- Achieves 14/16 test_rmw_implementation (matches rmw_zenoh_cpp)
- All ros2cli tests pass (ros2node, ros2service, ros2action,
  ros2interface, ros2topic)
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

Successfully merging this pull request may close these issues.

1 participant