Skip to content

Call the real fini function in tests that inject a fini error - #3458

Merged
ahcorde merged 1 commit into
ros2:rollingfrom
mjcarroll:fix-test-fini-leaks
Dec 2, 2026
Merged

ahcorde merged 1 commit into
ros2:rollingfrom
mjcarroll:fix-test-fini-leaks

Conversation

@mjcarroll

Copy link
Copy Markdown
Member

Description

Tests that make a *_fini() function fail used patch_and_return, which replaces the function with one that only returns the error, so the object is never released and LeakSanitizer reports it. Use inject_on_return, as other tests here already do: it calls the real function first and then returns the injected error.

Changed for rcl_service_fini, rcl_client_fini, rcl_network_flow_endpoint_array_fini, rcutils_string_map_fini, rcl_lifecycle_transition_fini and rcl_wait_set_fini in the rclcpp and rclcpp_lifecycle tests. Test only. The affected targets (test_service, test_client, test_generic_client, test_generic_service, test_publisher, test_expand_topic_or_service_name and test_transition_wrapper) are clean under AddressSanitizer after the change.

rcl_lifecycle_state_machine_fini in test_lifecycle_node_errors is left alone, see the comment there.

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

inject_on_return can't forward the call on RHEL-like distributions (see the note in mocking_utils/patch.hpp), where it prints a warning and behaves like the old mock.

Tests that replaced rcl_service_fini(), rcl_client_fini(), rcl_network_flow_endpoint_array_fini(), rcutils_string_map_fini(), rcl_lifecycle_transition_fini() and rcl_wait_set_fini() with a function that only returns an error never released the object, which LeakSanitizer reports. Use inject_on_return(), like the surrounding tests already do, so the real function runs before the error is injected.

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

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 @ a1ef7f4
(empty report — no differences printed by abidiff)
✅ librclcpp.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp.so
  • Head: lib-pr/librclcpp.so @ a1ef7f4
(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 @ a1ef7f4
(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 @ a1ef7f4
(empty report — no differences printed by abidiff)

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

@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

@ahcorde
ahcorde merged commit 3e0ecd3 into ros2:rolling Dec 2, 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