From b8e92a8fe1dadd3c279b3a790995dd3a1c3f2c03 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 10 Dec 2016 17:50:02 +0100 Subject: [PATCH] Detect and diagnose a possible user error --- src/msg/msg_gos.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index ba4b478793..0abc0ce7b4 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -574,6 +574,14 @@ int MSG_comm_testany(xbt_dynar_t comms) */ void MSG_comm_destroy(msg_comm_t comm) { + /* Diagnose a possible user error: destroying a comm that is not done yet, and not detached either */ + if ((comm->s_comm->state == SIMIX_READY || comm->s_comm->state == SIMIX_RUNNING) + && (!static_cast(comm->s_comm)->detached)) + XBT_WARN("You are destroying a communication that is not done yet but %s. " + "This will lead to issues when the other side continues this communication. " + "Are you looking for MSG_task_dsend()?", + (comm->s_comm->state == SIMIX_READY ? "ready" : "running")); + xbt_free(comm); } -- 2.20.1