ros-controls / ros2_control

Generic and simple controls framework for ROS 2
https://control.ros.org
Apache License 2.0
433 stars 272 forks source link

Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (backport #1451) #1599

Open mergify[bot] opened 6 days ago

mergify[bot] commented 6 days ago

As reported in #1442, loading the robot_description through the topic will cause a segmentation fault or some undefined behaviors as the read and write methods real-time methods are continuously executed, and when the robot description is received and the resource_manager is to be initialized, there is no lock_guard of recursive mutex resources_lock_, which should avoid the RM to execute the components when they are changing state or being loaded and initialized

Fixes #1442


This is an automatic backport of pull request #1451 done by Mergify.

mergify[bot] commented 6 days ago

Cherry-pick of 25f2c97eb909c48b96384c7cff7f7f36be8ca509 has failed:

On branch mergify/bp/humble/pr-1451
Your branch is up to date with 'origin/humble'.

You are currently cherry-picking commit 25f2c97.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
    both modified:   hardware_interface/src/resource_manager.cpp

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

codecov[bot] commented 4 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.00%. Comparing base (c04a16f) to head (7fbec9c). Report is 4 commits behind head on humble.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## humble #1599 +/- ## ========================================== - Coverage 87.00% 87.00% -0.01% ========================================== Files 97 97 Lines 7505 7508 +3 Branches 677 677 ========================================== + Hits 6530 6532 +2 - Misses 688 689 +1 Partials 287 287 ``` | [Flag](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1599/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1599/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls) | `87.00% <100.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1599?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls) | Coverage Δ | | |---|---|---| | [hardware\_interface/src/resource\_manager.cpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1599?src=pr&el=tree&filepath=hardware_interface%2Fsrc%2Fresource_manager.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-aGFyZHdhcmVfaW50ZXJmYWNlL3NyYy9yZXNvdXJjZV9tYW5hZ2VyLmNwcA==) | `80.27% <100.00%> (+0.06%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1599/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls)