From 50c8dc6d96c3e805407a1f0ad0cfdaff7d1e6ff0 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 25 Dec 2019 22:29:51 +0100 Subject: [PATCH] Host may be null (fix crash with logs). --- src/s4u/s4u_Host.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 73195c55a4..5022080dd9 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -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) -- 2.20.1