Repository navigation
Conversation
…ient The introspection publisher stores a raw pointer to the clock's rcl handle and dereferences it when the service or client is finalized. Neither Service nor Client held a reference to the clock passed to configure_introspection(), so destroying the clock first (e.g. the node's clock when the node is destroyed before the service) left rcl_service_fini()/rcl_client_fini() reading freed memory. Found with AddressSanitizer. Signed-off-by: Michael Carroll <[email protected]>
ABI Compliance Check❌ Verdict: incompatible
❌
|
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
configure_introspection()passes the clock's rcl handle to rcl, which stores the raw pointer and dereferences it again inrcl_service_fini()/rcl_client_fini().ServiceandClientdidn't keep theClockalive, so if it is destroyed first (e.g. the node's clock, when the node is destroyed before the service) the finalizer reads freed memory.Keep the clock in
ServiceBase/ClientBase, declared before the rcl handle so it is destroyed after the handle is finalized.Found with AddressSanitizer (
heap-use-after-freeinrcl_clock_validfrom~Service, intest_service_introspection). Addsintrospection_keeps_clock_alive, which fails under ASan without the change.Is this user-facing behavior change?
No. The service/client now keep the introspection clock alive instead of reading freed memory.
Did you use Generative AI?
Yes, Claude Code, for diagnosing the ASan report and writing the change and the test. Built and tested with AddressSanitizer.
Additional Information
The existing fixture already hit this:
TearDown()resets the node, so the clock dies before the service member does.