From cd5258031316ffdc659d604d8f02c8ac8277aada Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 12 Mar 2022 11:47:26 +0100 Subject: [PATCH] Defuse a trap on refcounting activities by adding a comment --- src/kernel/actor/ActorImpl.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 9e889becf2..67c9d552cf 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -204,12 +204,14 @@ void ActorImpl::exit() suspended_ = false; exception_ = nullptr; - /* destroy the blocking synchro if any */ if (waiting_synchro_ != nullptr) { + /* Take an extra reference on the activity object that may be unref by Comm::finish() or friends */ + activity::ActivityImplPtr activity = waiting_synchro_; + activity->cancel(); + activity->set_state(activity::State::FAILED); + activity->post(); + activities_.remove(waiting_synchro_); - waiting_synchro_->cancel(); - waiting_synchro_->set_state(activity::State::FAILED); - waiting_synchro_->post(); waiting_synchro_ = nullptr; } for (auto const& activity : activities_) -- 2.20.1