Skip to content

Conversation

@DenisBiryukov91
Copy link
Contributor

Only drop channel handlers if throwing an exception in case of declaration/get failure

@github-actions
Copy link

PR missing one of the required labels: {'enhancement', 'internal', 'bug', 'breaking-change', 'documentation', 'dependencies', 'api-sync', 'new feature', 'ci'}

@DenisBiryukov91 DenisBiryukov91 added the bug Something isn't working label Feb 12, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical resource leak in channel handler cleanup when Zenoh API operations fail. The __ZENOH_RESULT_CHECK macro throws exceptions in exception mode (when err == nullptr), which would previously skip the cleanup code that followed it, causing handler leaks. Additionally, the PR corrects an inconsistent double-move pattern in two locations.

Changes:

  • Moves handler cleanup to occur before __ZENOH_RESULT_CHECK calls, conditional on err == nullptr to prevent resource leaks when exceptions are thrown
  • Fixes inconsistent ::z_move(*as_moved_c_ptr(...)) double-move pattern to use correct as_moved_c_ptr(...)
  • Ensures error code mode (err != nullptr) returns handlers to callers for proper management

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
include/zenoh/api/session.hxx Updated 5 channel handler cleanup locations in get, declare_queryable, declare_subscriber, liveliness_declare_subscriber, and liveliness_get
include/zenoh/api/querier.hxx Updated 2 channel handler cleanup locations in Querier::get and declare_matching_listener
include/zenoh/api/publisher.hxx Updated channel handler cleanup in Publisher::declare_matching_listener
include/zenoh/api/ext/session_ext.hxx Updated 2 channel handler cleanup locations in declare_querying_subscriber and declare_advanced_subscriber
include/zenoh/api/ext/advanced_subscriber.hxx Updated channel handler cleanup in AdvancedSubscriberBase::detect_publishers, fixed double-move pattern
include/zenoh/api/ext/advanced_publisher.hxx Updated channel handler cleanup in AdvancedPublisher::declare_matching_listener

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@milyin milyin merged commit ad2e5b7 into eclipse-zenoh:main Feb 12, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants