diff --git a/rclcpp/include/rclcpp/wait_set_policies/detail/storage_policy_common.hpp b/rclcpp/include/rclcpp/wait_set_policies/detail/storage_policy_common.hpp index 4f0075c..24ed8b9 100644 --- a/rclcpp/include/rclcpp/wait_set_policies/detail/storage_policy_common.hpp +++ b/rclcpp/include/rclcpp/wait_set_policies/detail/storage_policy_common.hpp @@ -73,7 +73,17 @@ protected: size_t services_from_waitables = 0; size_t events_from_waitables = 0; for (const auto & waitable_entry : waitables) { - rclcpp::Waitable & waitable = *waitable_entry.waitable.get(); + auto waitable_ptr_pair = get_raw_pointer_from_smart_pointer(waitable_entry.waitable); + if (nullptr == waitable_ptr_pair.second) { + if (HasStrongOwnership) { + throw std::runtime_error("unexpected condition, fixed storage policy needs pruning"); + } + // Flag for pruning. + needs_pruning_ = true; + continue; + } + + rclcpp::Waitable & waitable = *waitable_ptr_pair.second; subscriptions_from_waitables += waitable.get_number_of_ready_subscriptions(); guard_conditions_from_waitables += waitable.get_number_of_ready_guard_conditions(); timers_from_waitables += waitable.get_number_of_ready_timers();