Skip to content

Release wait sets and clients that the tests leak - #3455

Merged
mjcarroll merged 2 commits into
ros2:rollingfrom
mjcarroll:fix-test-wait-set-leaks
Dec 1, 2026
Merged

mjcarroll merged 2 commits into
ros2:rollingfrom
mjcarroll:fix-test-wait-set-leaks

Conversation

@mjcarroll

Copy link
Copy Markdown
Member

Description

Several tests leak rcl objects, which LeakSanitizer reports:

  • test_graph_listener: five tests call init_wait_set() through the test helper and never finalize the wait set. They now call mock_cleanup_wait_set() at the end, like the other tests in that file. test_graph_listener_shutdown_wait_fini_error_throw started the fixture's listener but cleaned up a different, unused one, so it now uses the one it starts.
  • rclcpp_action TestClient.is_ready and TestGenericClient.is_ready never call rcl_wait_set_fini() on the wait set they create.
  • TestClient.construction_and_destruction_rcl_errors replaced rcl_action_client_fini() with a function that only returns an error, so the client was never finalized. It uses inject_on_return now, which calls the real function first.

Test only. Found with AddressSanitizer, which is clean for these three targets after the change.

Is this user-facing behavior change?

No.

Did you use Generative AI?

Yes, Claude Code, for finding the causes and writing the change. Tested with AddressSanitizer.

Additional Information

test_graph_listener, and the is_ready tests of the action client and generic client, initialize an rcl wait set by hand and never finalize it. construction_and_destruction_rcl_errors replaces rcl_action_client_fini() with a function that only returns an error, so the client is never finalized. Finalize the wait sets, and call the real rcl_action_client_fini() before injecting the error. Found with LeakSanitizer.

Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

ABI Compliance Check

✅ Verdict: compatible

Library Verdict Summary
libcomponent_manager.so ✅ compatible No ABI changes detected.
librclcpp.so ✅ compatible No ABI changes detected.
librclcpp_action.so ✅ compatible No ABI changes detected.
librclcpp_lifecycle.so ✅ compatible No ABI changes detected.
✅ libcomponent_manager.so — full abidiff report

Compared:

  • Base: lib-base/libcomponent_manager.so
  • Head: lib-pr/libcomponent_manager.so @ 7551fc9
(empty report — no differences printed by abidiff)
✅ librclcpp.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp.so
  • Head: lib-pr/librclcpp.so @ 7551fc9
(empty report — no differences printed by abidiff)
✅ librclcpp_action.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_action.so
  • Head: lib-pr/librclcpp_action.so @ 7551fc9
(empty report — no differences printed by abidiff)
✅ librclcpp_lifecycle.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_lifecycle.so
  • Head: lib-pr/librclcpp_lifecycle.so @ 7551fc9
(empty report — no differences printed by abidiff)

Updated for commit 7551fc9 · check run · suppressions: /home/runner/work/_temp/ros2-abi-suppressions.txt

Comment thread rclcpp_action/test/test_client.cpp Outdated
{
{
auto mock = mocking_utils::patch_and_return(
auto mock = mocking_utils::inject_on_return(

@christophebedard christophebedard Nov 28, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

argh, I've made so many similar fixes. It's so easy to overlook the leaks this causes at this level.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, I'm excited to be in a place where we can consistently run everything under ASan again.

@mjcarroll

mjcarroll commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

CI for this PR, built together with #3452, #3453, #3454, #3455 and #3458 on one branch (all five merge cleanly): https://ci.ros2.org/job/ci_launcher/21407

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

…ashes on RHEL

Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
@mjcarroll
mjcarroll merged commit c2306a7 into ros2:rolling Dec 1, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants