Skip to content

jazzy: honor cancel() issued before spin() (backport ros2/rclcpp#3174) + sync with upstream jazzy 28.1.22 - #5

Merged
jplapp merged 14 commits into
jazzy-updatedfrom
jazzy-updated-honor-cancel-before-spin
Sep 15, 2026
Merged

jplapp merged 14 commits into
jazzy-updatedfrom
jazzy-updated-honor-cancel-before-spin

Conversation

@jplapp

@jplapp jplapp commented Sep 14, 2026 •

Copy link
Copy Markdown

Why

Executor::cancel() on jazzy only stores spinning = false. A cancel() issued before the spin thread has entered spin() is lost: spin() then sets spinning = true and runs until the process is killed.

tf2_ros::TransformListener::~TransformListener() does exactly executor_->cancel(); dedicated_listener_thread_->join();. Any node that owns a TransformListener and is destroyed shortly after construction (every gtest fixture that builds a node per test) can therefore hang forever in its destructor. This is what timed out amr_navigation test_swarm_planning in deep_cv drone build 76336: last log line, then 57 s of silence until ctest killed it.

Standalone reproducer against the current jazzy-updated (cancel, then spin in a thread, wait 3 s):

FAIL: spin() did not return within 3 s after cancel() issued before spin()

What

  • Cherry-pick of upstream honor cancel() issued before spin_until_future_complete(). ros2/rclcpp#3174 (a67972f3, rolling only): cancel() sets a held cancel_requested_ flag that the next spin consumes; the spin loops react to that flag only, and spinning is owned by the spin functions so is_spinning() stays true until a spin really returns. Conflicts were the jazzy Executor(Context) initializer list and the (void)this_thread_number line in MultiThreadedExecutor::run.
  • Same change applied to StaticSingleThreadedExecutor, which jazzy still ships and upstream no longer patches.
  • Sync with upstream: merge of ros2/rclcpp jazzy (28.1.22, 11 commits: reentrant callback groups for the events CBG executor and its scheduler race fix, context shutdown race, shutdown callback registration without the shutdown mutex, malformed set_parameters request hardening, ComponentManager executor-association check, MSVC compile fixes, changelogs). Clean merge, no conflicts; the fork's own commits (events executor default, matches_any_publishers() lookup, backward-ros, action expiry fixes) are untouched.

Verified

  • Upstream's new typed tests cancelBeforeSpinDoesNotHang, cancelRacingSpinDoesNotHang, spinAfterCancelBeforeSpin (part of the cherry-pick) pass for all five executor types (15/15).
  • Full test_executors suite against the patched library: 151 pass, one timing flake in MultiThreadedExecutor.spinAll (the test's own "waitable executed at least twice within 1 s" count, not the cancel path) that passes 50/50 on repeat.
  • The reproducer above prints PASS: spin() returned after cancel() issued before spin() against the patched library.
  • After the upstream merge, rebuilt and re-ran against the merged library: test_executors 152/152 (the 15 cancel tests included), test_context 8/8, test_parameter_service 10/10, test_events_cbg_executor_reentrant 1/1.
  • Upstream jazzy (28.1.22) does not carry honor cancel() issued before spin_until_future_complete(). ros2/rclcpp#3174 and no backport PR exists there; this branch is jazzy-updated + the backport + the upstream sync.
  • Pre-existing, not touched here: test_intra_process_manager does not compile on jazzy-updated since the improve lookup time for matches_any_publishers() ros2/rclcpp#3084 backport (d7c81509) because the test's mock PublisherBase has no get_gid(). The library itself builds; the deep_cv image does not build rclcpp tests.
  • deep_cv PR pinning ros_nav_dependencies.repos to this branch runs the full CI on it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQ4WGjY7nv1dR8zbyjipqY

marcoag and others added 14 commits June 11, 2026 09:39
(cherry picked from commit 45aef03)

Signed-off-by: Janosch Machowinski <JMachowinski@cellumation.com>
Signed-off-by: Marco A. Gutierrez <marcogg@marcogg.com>
Co-authored-by: Janosch Machowinski <jmachowinski@users.noreply.github.com>
Co-authored-by: Janosch Machowinski <JMachowinski@cellumation.com>
Signed-off-by: Marco A. Gutierrez <marcogg@marcogg.com>
Signed-off-by: Marco A. Gutierrez <marcogg@marcogg.com>
…nentManager (ros2#3190) (ros2#3197)

(cherry picked from commit d2d94d0)

Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Co-authored-by: Skyler Medeiros <skye.galaxy@proton.me>
Co-authored-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Co-authored-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Tomoya Fujita <fujita.tomoya@triorb.co.jp>
(cherry picked from commit b723878)

# Conflicts:
#	rclcpp/src/rclcpp/context.cpp

Co-authored-by: Tomoya Fujita <fujita.tomoya@triorb.co.jp>
…BGExecutor scheduler (ros2#3234) (ros2#3236)

* put in_queue under ready_callback_groups_mutex



* only remove from ready_callback_groups if in the queue



---------



(cherry picked from commit 4528e3c)

Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Co-authored-by: Skyler Medeiros <skye.galaxy@proton.me>
Co-authored-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Co-authored-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
…os2#3256) (ros2#3266)

(cherry picked from commit 2e5a8b9)

Signed-off-by: Janosch Machowinski <jmachowinski@users.noreply.github.com>
Co-authored-by: Bas Zalmstra <4995967+baszalmstra@users.noreply.github.com>
Co-authored-by: Janosch Machowinski <jmachowinski@users.noreply.github.com>
* honor cancel() issued before spin_until_future_complete().

Signed-off-by: Tomoya Fujita <tomoya.fujita825@gmail.com>

* is_spinning() returns false immediately after cancel() even though the executor is still executing work.

Signed-off-by: Tomoya Fujita <fujita.tomoya@triorb.co.jp>

---------

Signed-off-by: Tomoya Fujita <tomoya.fujita825@gmail.com>
Signed-off-by: Tomoya Fujita <fujita.tomoya@triorb.co.jp>
(cherry picked from commit a67972f)
Jazzy still ships the StaticSingleThreadedExecutor (removed on rolling), so
upstream ros2#3174 does not touch it. Apply the same cancel_requested_
handling here: a cancel issued before spin() is held until the next spin
consumes it, and the spin loops react to cancel_requested_ only.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQ4WGjY7nv1dR8zbyjipqY
@jplapp jplapp changed the title jazzy: honor cancel() issued before spin() (backport ros2/rclcpp#3174) jazzy: honor cancel() issued before spin() (backport ros2/rclcpp#3174) + sync with upstream jazzy 28.1.22 Sep 14, 2026
@jplapp
jplapp merged commit 549a41b into jazzy-updated Sep 15, 2026
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.

5 participants