Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "actually fix the memleak around smpi's process_data" and "try to plug a memleak"
[simgrid.git] / src / simix / ActorImpl.cpp
index 4e82f6b..935ca1b 100644 (file)
@@ -145,6 +145,7 @@ void SIMIX_process_empty_trash()
 }
 
 namespace simgrid {
+
 namespace simix {
 
 ActorImpl::~ActorImpl()
@@ -221,7 +222,7 @@ smx_activity_t ActorImpl::suspend(ActorImpl* issuer)
 
     return nullptr;
   } else {
-    return SIMIX_execution_start(this, "suspend", 0.0, 1.0, 0.0);
+    return SIMIX_execution_start("suspend", 0.0, 1.0, 0.0, this->host);
   }
 }
 
@@ -321,16 +322,6 @@ smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, v
 
   if (parent_process != nullptr) {
     process->ppid = parent_process->pid;
-/* SMPI process have their own data segment and each other inherit from their father */
-#if HAVE_SMPI
-    if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) {
-      if (parent_process->pid != 0) {
-        process->segment_index = parent_process->segment_index;
-      } else {
-        process->segment_index = process->pid - 1;
-      }
-    }
-#endif
   }
 
   process->code         = code;
@@ -347,7 +338,7 @@ smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, v
   if (host->extension<simgrid::simix::Host>() == nullptr)
     host->extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
 
-  /* Add the process to its host process list */
+  /* Add the process to its host's process list */
   host->extension<simgrid::simix::Host>()->process_list.push_back(*process);
 
   XBT_DEBUG("Start context '%s'", process->name.c_str());
@@ -357,10 +348,13 @@ smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, v
   XBT_DEBUG("Inserting %s(%s) in the to_run list", process->getCname(), host->getCname());
   simix_global->process_to_run.push_back(process);
   intrusive_ptr_add_ref(process);
-
   /* Tracing the process creation */
   TRACE_msg_process_create(process->getName(), process->pid, process->host);
 
+  /* The onCreation() signal must be delayed until there, where the pid and everything is set */
+  simgrid::s4u::ActorPtr tmp = process->iface(); // Passing this directly to onCreation will lead to crashes
+  simgrid::s4u::Actor::onCreation(tmp);
+
   return process;
 }
 
@@ -388,16 +382,6 @@ smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostn
 
   if (parent_process != nullptr) {
     process->ppid = parent_process->pid;
-    /* SMPI process have their own data segment and each other inherit from their father */
-#if HAVE_SMPI
-    if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) {
-      if (parent_process->pid != 0) {
-        process->segment_index = parent_process->segment_index;
-      } else {
-        process->segment_index = process->pid - 1;
-      }
-    }
-#endif
   }
 
   /* Process data for auto-restart */
@@ -500,10 +484,10 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
         boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(process->waiting_synchro);
 
     if (exec != nullptr) {
-      if (exec->surf_exec) {
-        exec->surf_exec->cancel();
-        exec->surf_exec->unref();
-        exec->surf_exec = nullptr;
+      if (exec->surfAction_) {
+        exec->surfAction_->cancel();
+        exec->surfAction_->unref();
+        exec->surfAction_ = nullptr;
       }
     } else if (comm != nullptr) {
       process->comms.remove(process->waiting_synchro);
@@ -552,8 +536,8 @@ void SIMIX_process_throw(smx_actor_t process, xbt_errcat_t cat, int value, const
 
     simgrid::kernel::activity::ExecImplPtr exec =
         boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(process->waiting_synchro);
-    if (exec != nullptr && exec->surf_exec)
-      exec->surf_exec->cancel();
+    if (exec != nullptr && exec->surfAction_)
+      exec->surfAction_->cancel();
 
     simgrid::kernel::activity::CommImplPtr comm =
         boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(process->waiting_synchro);
@@ -607,12 +591,12 @@ void SIMIX_process_killall(smx_actor_t issuer, int reset_pid)
     simix_process_maxpid = reset_pid;
 }
 
-void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest)
+void SIMIX_process_change_host(smx_actor_t actor, sg_host_t dest)
 {
-  xbt_assert((process != nullptr), "Invalid parameters");
-  simgrid::xbt::intrusive_erase(process->host->extension<simgrid::simix::Host>()->process_list, *process);
-  process->host = dest;
-  dest->extension<simgrid::simix::Host>()->process_list.push_back(*process);
+  xbt_assert((actor != nullptr), "Invalid parameters");
+  simgrid::xbt::intrusive_erase(actor->host->extension<simgrid::simix::Host>()->process_list, *actor);
+  actor->host = dest;
+  dest->extension<simgrid::simix::Host>()->process_list.push_back(*actor);
 }
 
 void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process)
@@ -744,11 +728,6 @@ void SIMIX_process_yield(smx_actor_t self)
   /* Ok, maestro returned control to us */
   XBT_DEBUG("Control returned to me: '%s'", self->name.c_str());
 
-  if (self->new_host) {
-    SIMIX_process_change_host(self, self->new_host);
-    self->new_host = nullptr;
-  }
-
   if (self->context->iwannadie){
     XBT_DEBUG("I wanna die!");
     self->finished = true;
@@ -778,8 +757,8 @@ void SIMIX_process_yield(smx_actor_t self)
     std::rethrow_exception(std::move(exception));
   }
 
-  if(SMPI_switch_data_segment && self->segment_index != -1){
-    SMPI_switch_data_segment(self->segment_index);
+  if(SMPI_switch_data_segment){
+    SMPI_switch_data_segment(self->pid);
   }
 }