Skip to content

Fix some memory issues pointed out by sanitizer - #271

Merged
rhaschke merged 1 commit into
moveit:masterfrom
v4hn:pr-master-asan
May 28, 2021
Merged

rhaschke merged 1 commit into
moveit:masterfrom
v4hn:pr-master-asan

Conversation

@v4hn

@v4hn v4hn commented May 27, 2021

Copy link
Copy Markdown
Contributor

Related to #268

@codecov

codecov Bot commented May 27, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #271 (22fb1ce) into master (ff4eb4e) will decrease coverage by 16.54%.
The diff coverage is n/a.

❗ Current head 22fb1ce differs from pull request most recent head 949024f. Consider uploading reports for the commit 949024f to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           master     #271       +/-   ##
===========================================
- Coverage   51.86%   35.32%   -16.53%     
===========================================
  Files         101       97        -4     
  Lines        6565     6246      -319     
===========================================
- Hits         3404     2206     -1198     
- Misses       3161     4040      +879     
Impacted Files Coverage Δ
core/src/stages/current_state.cpp 20.00% <ø> (-76.15%) ⬇️
...ude/moveit/task_constructor/stages/generate_pose.h 0.00% <0.00%> (-100.00%) ⬇️
...ude/moveit/task_constructor/stages/move_relative.h 0.00% <0.00%> (-100.00%) ⬇️
...e/moveit/task_constructor/solvers/cartesian_path.h 0.00% <0.00%> (-100.00%) ⬇️
.../moveit/task_constructor/stages/predicate_filter.h 0.00% <0.00%> (-100.00%) ⬇️
...moveit/task_constructor/solvers/pipeline_planner.h 0.00% <0.00%> (-100.00%) ⬇️
...veit/task_constructor/stages/generate_grasp_pose.h 0.00% <0.00%> (-100.00%) ⬇️
...veit/task_constructor/stages/generate_place_pose.h 0.00% <0.00%> (-100.00%) ⬇️
core/src/solvers/cartesian_path.cpp 0.00% <0.00%> (-85.29%) ⬇️
core/src/stages/generate_grasp_pose.cpp 0.00% <0.00%> (-76.56%) ⬇️
... and 32 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff4eb4e...949024f. Read the comment docs.

@rhaschke rhaschke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I approve the 1st and 3rd commits but don't understand why the 2nd one is necessary and why only for CurrentStage? Can you explain?

@v4hn

v4hn commented May 28, 2021

Copy link
Copy Markdown
Contributor Author

I [...] don't understand why the 2nd one is necessary and why only for CurrentStage? Can you explain?

CurrentState is the only primitive stage you wrapped into a ClassLoader-compatible plugin for now.
I believe you planned to use it with a GUI for building task structures.

But because ClassLoader intrinsically leaks memory (I gave the link in the commit) it makes sense to split all code that registers ClassLoader factories from all other functional library code to get clean memory management reports for the unrelated parts.

to work around ros/class_loader#131
and have all code using the `CurrentState` stage sanitize correctly
(unless they use it through ClassLoader).
@v4hn
v4hn force-pushed the pr-master-asan branch from 22fb1ce to 949024f Compare May 28, 2021 07:44
@rhaschke

Copy link
Copy Markdown
Contributor

Thanks for the explanation. You are right, I wanted to enable GUI-based assembly of tasks in the past...
I think, locally, I'm using a suppression file to ignore the known ClassLoader issues. However, interestingly, GHA didn't complain either, which made me wonder, why these changes are necessary.
https://github.com/ros-planning/moveit_task_constructor/actions/runs/883749251

Actually, I don't like this workaround very much but suggest using a suppression file instead. There is an explicit reminder that suppressions were used so that the issue isn't silently hidden.

But there is another issue: As I merged #254 after having merged the (originally successful) asan checks, the build fails now, because move_group wasn't compiled against libasan.so, but loads a plugin that was:
https://github.com/ros-planning/moveit_task_constructor/runs/2689556141

A possible workaround is to LD_PRELOAD=libasan.so.x via an <env> setting in the .test file.
However, this is fragile, because the version of libasan will change across different OSes. Removing the asan check, isn't a nice option either.

@v4hn

v4hn commented May 28, 2021

Copy link
Copy Markdown
Contributor Author

However, interestingly, GHA didn't complain either

I was wondering why that did not come up, yes.

Actually, I don't like this workaround very much but suggest using a suppression file instead. There is an explicit reminder that suppressions were used so that the issue isn't silently hidden.

This is not a workaround at all in my opinion but simple cleanup. Using/linking a regular C++ class should not invoke magic code to add entries to unused(!) global datastructures that even leak memory. I was surprised to find that you added the macro in the regular cpp file of the class.

Incidentally I just followed a suggestion in a potential warning of class loader. I've never seen the warning, but it looks like there can(could?) actually be issues if you link a library with class-loadable datastructures.

It would still be nice to suppress the same warnings in the new library if we ever write tests for it.

because move_group wasn't compiled against libasan.so, but loads a plugin that was
A possible workaround is to LD_PRELOAD=libasan.so.x via an setting in the .test file.

Yes, I've noticed similar issues locally (same with RViz and the MTC display/panel, though these are not relevant for CI tests).
I did not know about the workaround though.
We could disable the flag for plugins (though that's likely somewhat cumbersome).
If the workaround will not result in any misbehavior (I guess it might be problematic if a plugin exchanges ownership of allocated memory with the main node?) couldn't we just add the environment flag to the asan job?
Alternatively we could of course also add another environment flag to detect in the respective .test files.
I don't see much of a problem if we can define the library version in the ci.yaml.

@rhaschke
rhaschke merged commit 84d668b into moveit:master May 28, 2021
@JafarAbdi

Copy link
Copy Markdown
Member

You are right, I wanted to enable GUI-based assembly of tasks in the past...

Are you still planning to do so.? I'm asking because one thing I've been working on during the last few lockdowns is to create a similar application, this's the current status

mtc_gui.mp4

As you can see it's not ready yet, but I do still slowly work on it when I have free time,

I wonder if you have an architect document that may help me during the development

@rhaschke

Copy link
Copy Markdown
Contributor

@JafarAbdi: See #278.

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.

3 participants