This repository has been archived by the owner on Feb 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 497
SensorManager deadlock in PublishPerformanceMetrics if multiple SensorContainers have sensors #2902
Comments
scpeters
added a commit
to scpeters/gazebo_ros_pkgs
that referenced
this issue
Dec 12, 2020
We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. The link_states and model_states topics currently use an advertise mechanism with callbacks when a subscriber connects or disconnects, so I've used that same pattern for the performance_metrics topic. This also helps workaround the deadlock documented in ros-simulation#1175 and gazebosim/gazebo-classic#2902. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to scpeters/gazebo_ros_pkgs
that referenced
this issue
Dec 12, 2020
We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. The link_states and model_states topics currently use an advertise mechanism with callbacks when a subscriber connects or disconnects, so I've used that same pattern for the performance_metrics topic. This also helps workaround the deadlock documented in ros-simulation#1175 and gazebosim/gazebo-classic#2902. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to ros-simulation/gazebo_ros_pkgs
that referenced
this issue
Dec 15, 2020
We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. The link_states and model_states topics currently use an advertise mechanism with callbacks when a subscriber connects or disconnects, so I've used that same pattern for the performance_metrics topic. This also helps workaround the deadlock documented in #1175 and gazebosim/gazebo-classic#2902. This also adds a GAZEBO_ROS_HAS_PERFORMANCE_METRICS macro that reduces duplication of the version checking logic for performance metrics in gazebo and adds fixes some doc-string and typos in existing code Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to scpeters/gazebo_ros_pkgs
that referenced
this issue
Dec 22, 2020
We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. This changes gazebo_ros_init to only subscribe to the gazebo topic if there are any subscribers to the corresponding ROS topic. While advertiser callbacks are used in ROS 1 but are not yet in ROS2, here we use polling in the GazeboRosInitPrivate::PublishSimTime callback to check for subscribers since it is called for each Gazebo time step. This also helps workaround the deadlock documented in ros-simulation#1175 and gazebosim/gazebo-classic#2902. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to ros-simulation/gazebo_ros_pkgs
that referenced
this issue
Dec 22, 2020
Backport of #1202 to melodic-devel. We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. The link_states and model_states topics currently use an advertise mechanism with callbacks when a subscriber connects or disconnects, so I've used that same pattern for the performance_metrics topic. This also helps workaround the deadlock documented in #1175 and gazebosim/gazebo-classic#2902. This also adds a GAZEBO_ROS_HAS_PERFORMANCE_METRICS macro that reduces duplication of the version checking logic for performance metrics in gazebo and adds fixes some doc-string and typos in existing code Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to ros-simulation/gazebo_ros_pkgs
that referenced
this issue
Dec 22, 2020
…1205) We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. This changes gazebo_ros_init to only subscribe to the gazebo topic if there are any subscribers to the corresponding ROS topic. While advertiser callbacks are used in ROS 1 but are not yet in ROS2, here we use polling in the GazeboRosInitPrivate::PublishSimTime callback to check for subscribers since it is called for each Gazebo time step. This also helps workaround the deadlock documented in #1175 and gazebosim/gazebo-classic#2902. This also adds a macro to reduce duplication of the version checking logic. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to scpeters/gazebo_ros_pkgs
that referenced
this issue
Dec 22, 2020
We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. The link_states and model_states topics currently use an advertise mechanism with callbacks when a subscriber connects or disconnects, so I've used that same pattern for the performance_metrics topic. This also helps workaround the deadlock documented in ros-simulation#1175 and gazebosim/gazebo-classic#2902. Signed-off-by: Steve Peters <[email protected]>
This was referenced Dec 22, 2020
scpeters
added a commit
to ros-simulation/gazebo_ros_pkgs
that referenced
this issue
Dec 23, 2020
Backport of #1202 to kinetic-level. We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. The link_states and model_states topics currently use an advertise mechanism with callbacks when a subscriber connects or disconnects, so I've used that same pattern for the performance_metrics topic. This also helps workaround the deadlock documented in #1175 and gazebosim/gazebo-classic#2902. This also adds a GAZEBO_ROS_HAS_PERFORMANCE_METRICS macro that reduces duplication of the version checking logic for performance metrics in gazebo and adds fixes some doc-string and typos in existing code Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to scpeters/gazebo
that referenced
this issue
Jan 17, 2021
Currently the PublishPerformanceMetrics function is called within SensorManager.cc by each SensorContainer with protection by the mutex of each SensorContainer. This leads to a deadlock when a world has sensors in more than one container (i.e. more than one category of sensors) as described in gazebosim#2902. Since the PublishPerformanceMetrics function is not a member function of SensorContainer and uses only global variables, the function can be called by only the SensorManager thread instead of all the SensorContainer threads. It is also left unprotected by a mutex, as it may not be needed. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to scpeters/gazebo
that referenced
this issue
Jan 20, 2021
Currently the PublishPerformanceMetrics function is called within SensorManager.cc by each SensorContainer with protection by the mutex of each SensorContainer. This leads to a deadlock when a world has sensors in more than one container (i.e. more than one category of sensors) as described in gazebosim#2902. Since the PublishPerformanceMetrics function is not a member function of SensorContainer and uses only global variables, the function can be called by only the SensorManager thread instead of all the SensorContainer threads. It is also left unprotected by a mutex, as it may not be needed. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to scpeters/gazebo
that referenced
this issue
Jan 20, 2021
Currently the PublishPerformanceMetrics function is called within SensorManager.cc by each SensorContainer with protection by the mutex of each SensorContainer. This leads to a deadlock when a world has sensors in more than one container (i.e. more than one category of sensors) as described in gazebosim#2902. Since the PublishPerformanceMetrics function is not a member function of SensorContainer and uses only global variables, the function can be called by the SensorManager thread instead of by each SensorContainer thread. This change will avoid the deadlock. Signed-off-by: Steve Peters <[email protected]>
An easy way to reproduce this is to load the
|
test and fix in #2917 |
scpeters
added a commit
that referenced
this issue
Jan 21, 2021
* Add test for performance metrics deadlock Load the pr2 world with --lockstep and then subscribe to /gazebo/performance_metrics to reproduce the deadlock. * Fix deadlock when publishing performance metrics Currently the PublishPerformanceMetrics function is called within SensorManager.cc by each SensorContainer with protection by the mutex of each SensorContainer. This leads to a deadlock when a world has sensors in more than one container (i.e. more than one category of sensors) as described in #2902. Since the PublishPerformanceMetrics function is not a member function of SensorContainer and uses only global variables, the function can be called by the SensorManager thread instead of by each SensorContainer thread. This change will avoid the deadlock. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to scpeters/gazebo
that referenced
this issue
Jan 26, 2021
* Add test for performance metrics deadlock Load the pr2 world with --lockstep and then subscribe to /gazebo/performance_metrics to reproduce the deadlock. * Fix deadlock when publishing performance metrics Currently the PublishPerformanceMetrics function is called within SensorManager.cc by each SensorContainer with protection by the mutex of each SensorContainer. This leads to a deadlock when a world has sensors in more than one container (i.e. more than one category of sensors) as described in gazebosim#2902. Since the PublishPerformanceMetrics function is not a member function of SensorContainer and uses only global variables, the function can be called by the SensorManager thread instead of by each SensorContainer thread. This change will avoid the deadlock. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
to scpeters/gazebo
that referenced
this issue
Jan 26, 2021
* Add test for performance metrics deadlock Load the pr2 world with --lockstep and then subscribe to /gazebo/performance_metrics to reproduce the deadlock. * Fix deadlock when publishing performance metrics Currently the PublishPerformanceMetrics function is called within SensorManager.cc by each SensorContainer with protection by the mutex of each SensorContainer. This leads to a deadlock when a world has sensors in more than one container (i.e. more than one category of sensors) as described in gazebosim#2902. Since the PublishPerformanceMetrics function is not a member function of SensorContainer and uses only global variables, the function can be called by the SensorManager thread instead of by each SensorContainer thread. This change will avoid the deadlock. Signed-off-by: Steve Peters <[email protected]>
scpeters
added a commit
that referenced
this issue
Jan 28, 2021
* Add test for performance metrics deadlock Load the pr2 world with --lockstep and then subscribe to /gazebo/performance_metrics to reproduce the deadlock. * Fix deadlock when publishing performance metrics Currently the PublishPerformanceMetrics function is called within SensorManager.cc by each SensorContainer with protection by the mutex of each SensorContainer. This leads to a deadlock when a world has sensors in more than one container (i.e. more than one category of sensors) as described in #2902. Since the PublishPerformanceMetrics function is not a member function of SensorContainer and uses only global variables, the function can be called by the SensorManager thread instead of by each SensorContainer thread. This change will avoid the deadlock. Signed-off-by: Steve Peters <[email protected]>
jacobperron
pushed a commit
to ros-simulation/gazebo_ros_pkgs
that referenced
this issue
Feb 3, 2021
…1205) We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. This changes gazebo_ros_init to only subscribe to the gazebo topic if there are any subscribers to the corresponding ROS topic. While advertiser callbacks are used in ROS 1 but are not yet in ROS2, here we use polling in the GazeboRosInitPrivate::PublishSimTime callback to check for subscribers since it is called for each Gazebo time step. This also helps workaround the deadlock documented in #1175 and gazebosim/gazebo-classic#2902. This also adds a macro to reduce duplication of the version checking logic. Signed-off-by: Steve Peters <[email protected]>
jacobperron
pushed a commit
to ros-simulation/gazebo_ros_pkgs
that referenced
this issue
Mar 11, 2021
…1205) We are currently subscribing to the /gazebo/performance_metrics topic even if there are no subscribers to the ROS topic forwarding this data. This changes gazebo_ros_init to only subscribe to the gazebo topic if there are any subscribers to the corresponding ROS topic. While advertiser callbacks are used in ROS 1 but are not yet in ROS2, here we use polling in the GazeboRosInitPrivate::PublishSimTime callback to check for subscribers since it is called for each Gazebo time step. This also helps workaround the deadlock documented in #1175 and gazebosim/gazebo-classic#2902. This also adds a macro to reduce duplication of the version checking logic. Signed-off-by: Steve Peters <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I've noticed a deadlock in SensorManager::PublishPerformanceMetrics (added in #2819) when subscribing to
/gazebo/performance_metrics
with a world that contains sensors in more than oneSensorContainer
. Recalling that eachSensorContainer
has its own thread and manages sensors of the same SensorCategory (IMAGE
,RAY
, orOTHER
), this could happen with a model containing aCameraSensor
and aRaySensor
or aCameraSensor
and anImuSensor
. For example, if you load the PR2 world and open the Image viewer fromWindow -> Topic Visualization
, the images will update until you also open the/gazebo/performance_metrics
topic in the viewer.I've collected a backtrace with two
SensorContainer
objects callingSensorManager::GetSensor
at the same time and waiting on mutexes:The text was updated successfully, but these errors were encountered: