Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Host may be null (fix crash with logs).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 25 Dec 2019 21:29:51 +0000 (22:29 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 26 Dec 2019 11:12:26 +0000 (12:12 +0100)
src/s4u/s4u_Host.cpp

index 73195c5..5022080 100644 (file)
@@ -660,7 +660,13 @@ sg_host_t sg_host_self()
 /* needs to be public and without simcall for exceptions and logging events */
 const char* sg_host_self_get_name()
 {
-  return SIMIX_is_maestro() ? "" : simgrid::kernel::actor::ActorImpl::self()->get_host()->get_cname();
+  const char* res = "";
+  if (not SIMIX_is_maestro()) {
+    simgrid::s4u::Host* host = simgrid::kernel::actor::ActorImpl::self()->get_host();
+    if (host != nullptr)
+      res = host->get_cname();
+  }
+  return res;
 }
 
 double sg_host_load(sg_host_t host)