Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in tracetools::get_symbol() #2104

Conversation

christophebedard
Copy link
Member

@christophebedard christophebedard commented Feb 15, 2023

Part of ros2/ros2_tracing#34

Requires ros2/ros2_tracing#43

Requires ros2/ros2_tracing#46 to help avoid memory allocations when the tracepoint isn't enabled.

Signed-off-by: Christophe Bedard christophe.bedard@apex.ai

@christophebedard
Copy link
Member Author

This is the simplest fix, but it could be improved. For example, we could first check if the tracepoint is actually enabled before calling tracetools::get_symbol() and allocating. This would require changes in tracetools, though. See ros2/ros2_tracing#43 (comment)

@alsora
Copy link
Collaborator

alsora commented Feb 15, 2023

Isn't the macro sufficient to prevent using this code if tracetools is disabled?
Or do we support both "compile time disabled" and "runtime disabled" ?

@mjcarroll
Copy link
Member

Or do we support both "compile time disabled" and "runtime disabled" ?

When building with tracepoints enabled, there will be some runtime associated here, even if the tracepoints are not actively being used. I think this is more important as we are discussing building with tracepoints by default in the binary packages.

@christophebedard
Copy link
Member Author

In this case, this tracepoint is only triggered during initialization, so the overhead is fairly small. But, yes, being able to not do this kind of processing if a tracepoint is disabled at runtime would be much better.

Since that change (as described here ros2/ros2_tracing#43 (comment)) requires modifications to tracetools and to potential downstream packages (including rclcpp for this exact instance), I could first add TRACEPOINT_ENABLED(...) and DO_TRACEPOINT(...) to tracetools. Then we'd only need to modify rclcpp once.

@christophebedard
Copy link
Member Author

christophebedard commented Feb 23, 2023

Testing --packages-above tracetools test_tracetools rclcpp:

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

Includes:

@christophebedard christophebedard force-pushed the christophebedard/fix-memory-leak-in-tracetools-get-symbol branch from 70d0953 to 41e046a Compare February 23, 2023 19:20
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
@christophebedard christophebedard force-pushed the christophebedard/fix-memory-leak-in-tracetools-get-symbol branch from 41e046a to 432d1f4 Compare February 23, 2023 21:27
Copy link
Member

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

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

Another approval for good measure

@christophebedard
Copy link
Member Author

@mjcarroll thanks 😆

I can't merge this PR, so I'll let you merge it.

@mjcarroll mjcarroll merged commit 72c05ec into ros2:rolling Feb 28, 2023
@christophebedard christophebedard deleted the christophebedard/fix-memory-leak-in-tracetools-get-symbol branch February 28, 2023 22:42
mjcarroll added a commit that referenced this pull request Mar 1, 2023
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request Apr 28, 2023
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
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.

None yet

3 participants