From: Martin Quinson Date: Sat, 12 Mar 2022 10:47:26 +0000 (+0100) Subject: Defuse a trap on refcounting activities by adding a comment X-Git-Tag: v3.31~149 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/cd5258031316ffdc659d604d8f02c8ac8277aada?ds=sidebyside Defuse a trap on refcounting activities by adding a comment --- 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_)