From: Arnaud Giersch Date: Sat, 23 Apr 2022 15:12:02 +0000 (+0200) Subject: Don't throw exception in destructor (sonar). X-Git-Tag: v3.32~302 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/38bbcc5c13fd819b76fbc08ed7f46f292862fe06 Don't throw exception in destructor (sonar). --- diff --git a/src/kernel/lmm/System.cpp b/src/kernel/lmm/System.cpp index b4e9118161..33dc9cf013 100644 --- a/src/kernel/lmm/System.cpp +++ b/src/kernel/lmm/System.cpp @@ -176,9 +176,10 @@ System::System(bool selective_update) : selective_update_active(selective_update System::~System() { while (Variable* var = extract_variable()) { - std::string demangled = boost::core::demangle(var->id_ ? typeid(*var->id_).name() : "(unidentified)"); - XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", demangled.c_str(), - var->rank_); + const char* name = var->id_ ? typeid(*var->id_).name() : "(unidentified)"; + boost::core::scoped_demangled_name demangled(name); + XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", + demangled.get() ? demangled.get() : name, var->rank_); var_free(var); } while (Constraint* cnst = extract_constraint()) diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 488aca5f7f..de2ba8fe06 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -37,12 +37,17 @@ HostImpl::~HostImpl() { /* All actors should be gone when the host is turned off (by the end of the simulation). */ if (not actor_list_.empty()) { - std::string msg = "Shutting down host, but it's not empty:"; - for (auto const& actor : actor_list_) - msg += "\n\t" + std::string(actor.get_name()); - - EngineImpl::get_instance()->display_all_actor_status(); - xbt_die("%s", msg.c_str()); + const char* msg = "Shutting down host, but it's not empty"; + try { + std::string actors; + for (auto const& actor : actor_list_) + actors += "\n\t" + std::string(actor.get_name()); + + EngineImpl::get_instance()->display_all_actor_status(); + xbt_die("%s:%s", msg, actors.c_str()); + } catch (std::bad_alloc& ba) { + xbt_die("%s (cannot print actor list: %s)", msg, ba.what()); + } } for (auto const& arg : actors_at_boot_) delete arg;