Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Improve an error message: comms must be detached if you don't plan to wait() on them
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 2 Feb 2021 18:49:33 +0000 (19:49 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 2 Feb 2021 20:19:48 +0000 (21:19 +0100)
Fix https://framagit.org/simgrid/simgrid/-/issues/60

src/s4u/s4u_Comm.cpp

index 8548847..0042ba9 100644 (file)
@@ -23,9 +23,13 @@ Comm::~Comm()
 {
   if (state_ == State::STARTED && not detached_ &&
       (pimpl_ == nullptr || pimpl_->state_ == kernel::activity::State::RUNNING)) {
-    XBT_INFO("Comm %p freed before its completion. Detached: %d, State: %d", this, detached_, (int)state_);
+    if (not detached_)
+      XBT_INFO("Comm %p freed before its completion. Did you forget to detach it? (state: %s)", this, get_state_str());
+    else
+      XBT_INFO("Detached comm %p freed before its completion, please report that bug along with a MWE (state: %s).",
+               this, get_state_str());
     if (pimpl_ != nullptr)
-      XBT_INFO("pimpl_->state: %d", static_cast<int>(pimpl_->state_));
+      XBT_INFO("pimpl_->state: %s", pimpl_->get_state_str());
     else
       XBT_INFO("pimpl_ is null");
     xbt_backtrace_display_current();