Skip to content

Commit

Permalink
added lock to prevent simultaneous access of on_shutdown_callbacks_ w…
Browse files Browse the repository at this point in the history
…hich led to a race condition (seg fault) when creating multiple executors (multithreaded)

Signed-off-by: Joshua Hampp <[email protected]>
  • Loading branch information
Joshua Hampp committed Apr 15, 2021
1 parent ec70642 commit 6eb34a8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions rclcpp/src/rclcpp/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ Context::shutdown(const std::string & reason)
rclcpp::Context::OnShutdownCallback
Context::on_shutdown(OnShutdownCallback callback)
{
std::lock_guard<std::mutex> lock(on_shutdown_callbacks_mutex_);
on_shutdown_callbacks_.push_back(callback);
return callback;
}
Expand Down

0 comments on commit 6eb34a8

Please sign in to comment.