Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Assert that there is no memory leak (help scan-build).
[simgrid.git] / src / instr / instr_platform.cpp
index 1901f25..6a9ca45 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -160,6 +160,7 @@ static void instr_netzone_on_creation(simgrid::s4u::NetZone& netzone)
   std::string id = netzone.get_name();
   if (simgrid::instr::Container::get_root() == nullptr) {
     simgrid::instr::NetZoneContainer* root = new simgrid::instr::NetZoneContainer(id, 0, nullptr);
+    xbt_assert(simgrid::instr::Container::get_root() == root);
 
     if (TRACE_smpi_is_enabled()) {
       simgrid::instr::ContainerType* mpi = root->type_->by_name_or_create<simgrid::instr::ContainerType>("MPI");
@@ -306,7 +307,7 @@ static void instr_actor_on_creation(simgrid::s4u::ActorPtr actor)
 
   std::string container_name = instr_pid(actor.get());
   actor->on_exit(
-      [container_name](int status, void* actor) {
+      [container_name](int status, void*) {
         if (status == SMX_EXIT_FAILURE)
           // kill means that this actor no longer exists, let's destroy it
           simgrid::instr::Container::by_name(container_name)->remove_from_parent();
@@ -372,6 +373,11 @@ void instr_define_callbacks()
 
   if (TRACE_actor_is_enabled()) {
     simgrid::s4u::Actor::on_creation.connect(instr_actor_on_creation);
+    simgrid::s4u::Actor::on_destruction.connect([](simgrid::s4u::ActorPtr actor) {
+      auto container = simgrid::instr::Container::by_name_or_null(instr_pid(actor.get()));
+      if (container != nullptr)
+        container->remove_from_parent();
+    });
     simgrid::s4u::Actor::on_suspend.connect([](simgrid::s4u::ActorPtr actor) {
       simgrid::instr::Container::by_name(instr_pid(actor.get()))->get_state("ACTOR_STATE")->push_event("suspend");
     });