Repository navigation
Call the real fini function in tests that inject a fini error - #3458
Merged
Merged
Conversation
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>
ABI Compliance Check✅ Verdict: compatible
✅
|
This was referenced Nov 29, 2026
Member
Author
ahcorde
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Tests that make a
*_fini()function fail usedpatch_and_return, which replaces the function with one that only returns the error, so the object is never released and LeakSanitizer reports it. Useinject_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_finiandrcl_wait_set_finiin 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_nameandtest_transition_wrapper) are clean under AddressSanitizer after the change.rcl_lifecycle_state_machine_finiintest_lifecycle_node_errorsis 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_returncan't forward the call on RHEL-like distributions (see the note inmocking_utils/patch.hpp), where it prints a warning and behaves like the old mock.