Skip to content

Fix bug in timers lifecycle for events executor (backport #2586) - #3435

Open
376636851 wants to merge 1 commit into
ros2:jazzyfrom
376636851:backport-2586-jazzy
Open

376636851 wants to merge 1 commit into
ros2:jazzyfrom
376636851:backport-2586-jazzy

Conversation

@376636851

Copy link
Copy Markdown

Backport of #2586 to jazzy. The EventsExecutor keys its entity collections by rcl handle address. When an entity is destroyed and a new one is created at the same address, the stale weak entry was kept and the new entity was never registered (on_added was skipped). For timers this means the new timer never fires; for subscriptions the new message callback is never set, so the subscription callback is never invoked.

Remove expired entities from the current collection before updating it, as done in rolling.

Conflict resolution: jazzy uses current_entities_collection_ (a pointer) and collection_mutex_ instead of current_collection_ and mutex_; the upstream change was adapted to those names. The regression test is cherry-picked unchanged.

  • Remove expired timers before updating the collection
  • Add regression test for reinitialized timers bug
  • Add missing includes
  • Relocate test under the executors directory
  • Extend test to run with all supported executors
  • Adjust comment in fix to make it more generic
  • Apply ament clang format to test
  • Fix uncrustify findings

(cherry picked from commit 496c455)

Description

Fixes # (issue)

Is this user-facing behavior change?

Did you use Generative AI?

Additional Information

Backport of ros2#2586 to jazzy. The EventsExecutor keys its entity
collections by rcl handle address. When an entity is destroyed and a new
one is created at the same address, the stale weak entry was kept and
the new entity was never registered (on_added was skipped). For timers
this means the new timer never fires; for subscriptions the new message
callback is never set, so the subscription callback is never invoked.

Remove expired entities from the current collection before updating it,
as done in rolling.

Conflict resolution: jazzy uses current_entities_collection_ (a pointer)
and collection_mutex_ instead of current_collection_ and mutex_; the
upstream change was adapted to those names. The regression test is
cherry-picked unchanged.

* Remove expired timers before updating the collection
* Add regression test for reinitialized timers bug
* Add missing includes
* Relocate test under the executors directory
* Extend test to run with all supported executors
* Adjust comment in fix to make it more generic
* Apply ament clang format to test
* Fix uncrustify findings

Signed-off-by: Alexis Pojomovsky <[email protected]>
Co-authored-by: Alexis Pojomovsky <[email protected]>
(cherry picked from commit 496c455)
Signed-off-by: wufujian <[email protected]>
@376636851

Copy link
Copy Markdown
Author

@ahcorde @alsora This is a backport of #2586 to Jazzy, which was never backported.
The bug still reproduces on the current jazzy branch: test_reinitialized_timers hangs
in the EventsExecutor case in 20/20 runs without this change, and passes in 20/20 runs
with it. Could you please take a look? Thanks!

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.

2 participants