Skip to content

fix(rmw_event): reject unsupported event types in *_event_init - #61

Merged
benaliabderrahmane merged 1 commit into
develfrom
fix/event-init-reject-unsupported
Sep 8, 2026
Merged

fix(rmw_event): reject unsupported event types in *_event_init#61
benaliabderrahmane merged 1 commit into
develfrom
fix/event-init-reject-unsupported

Conversation

@benaliabderrahmane

Copy link
Copy Markdown
Owner

Ports the July EventsExecutor crash fix to devel — it was committed on fix/transient-local-late-joiner-replay (3d246ed) but that branch's feature was superseded by #60 and this fix never landed with it.

Symptom (reproduced today, first unix_socket run of the ros2-benchmark-container suite on devel e819eb5):

terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'
  what():  failed to set the on new message callback for Event: error not set

Every subscription crashes under EventsExecutor (irobot_benchmark's default). *_event_init returned RMW_RET_OK for every event type while rmw_event_type_is_supported() returns false and rmw_event_set_callback() returns UNSUPPORTED without an error message — so rclcpp built a live handler for the default incompatible-QoS event and the failure surfaced later, unhandled, at callback registration.

Fix: check rmw_event_type_is_supported() in both *_event_init functions (RMW_SET_ERROR_MSG + RMW_RET_UNSUPPORTED), which rclcpp handles as the expected UnsupportedEventTypeException. Adds test_rmw_event.cpp (verified fail-then-pass in July). 15/15 ctest green on this branch.

Clean cherry-pick of 3d246ed; no adaptation was needed. The benchmark image is pinned to this commit until it merges.

rmw_publisher_event_init/rmw_subscription_event_init always returned
RMW_RET_OK regardless of event_type, while rmw_event_type_is_supported()
always returns false and rmw_event_set_callback() always returns
RMW_RET_UNSUPPORTED without setting an error message.

rclcpp's EventHandler constructor treats RMW_RET_UNSUPPORTED from
*_event_init specially (UnsupportedEventTypeException, swallowed by
SubscriptionBase::bind_event_callbacks for the default incompatible-QoS/
type callbacks every subscription gets). Since init always "succeeded",
rclcpp built a live event handler for an event we don't actually
support, and the failure only surfaced later, unhandled, when the
EventsExecutor tried to register its callback - crashing with
"failed to set the on new message callback for Event: error not set"
on every subscription, under EventsExecutor specifically.

Fix: check rmw_event_type_is_supported() in both *_event_init functions
before reporting success, matching the RMW_SET_ERROR_MSG + UNSUPPORTED
pattern already used elsewhere in this file (e.g.
rmw_subscription_set_content_filter).

Adds test/test_rmw_event.cpp, confirmed to fail on the old behavior and
pass after the fix. Full existing suite (128 tests) still passes.

Found while verifying rmw_unix_socket_cpp against ros2-benchmark-container
and performance_test: EventsExecutor (default in both) crashed on every
pub/sub topology; SingleThreadedExecutor/MultiThreadedExecutor were
unaffected.

@benaliabderrahmane benaliabderrahmane left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

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