Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Display a msg when contexts are killed by uncatched exceptions
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 29 Aug 2018 09:35:10 +0000 (11:35 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 29 Aug 2018 09:53:41 +0000 (11:53 +0200)
and when I want to really kill an actor (eg when its host is turned
off), I launch an uncatchable kernel::Context::StopRequest instead of
a catchable simgrid::HostFailureException (which will be used in case
of remote exec and similar)

Maybe there should be a config flag to decide if we want to kill the
simulation when an actor fails. The current setting forces the user to
add try/catch (simgrid::Exception) around their main functions. That's
not a bad thing either, not sure.

src/kernel/context/Context.hpp
src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextThread.cpp
src/kernel/context/ContextUnix.cpp
src/simix/ActorImpl.cpp

index 674f02d..ac073ab 100644 (file)
@@ -58,9 +58,14 @@ public:
   class StopRequest {
     /** @brief Exception launched to kill a process, in order to properly unwind its stack and release RAII stuff
      *
-     * Nope, Sonar, this should not inherit of std::exception.
+     * Nope, Sonar, this should not inherit of std::exception nor of simgrid::Exception.
      * Otherwise, users may accidentally catch it with a try {} catch (std::exception)
      */
+  public:
+    StopRequest() = default;
+    StopRequest(std::string msg) : msg_(msg) { }
+  private:
+    std::string msg_;
   };
   bool iwannadie;
 
index e5b557f..121fa2b 100644 (file)
@@ -116,8 +116,9 @@ void BoostContext::wrapper(BoostContext::arg_type arg)
     (*context)();
   } catch (StopRequest const&) {
     XBT_DEBUG("Caught a StopRequest");
-  } catch (simgrid::HostFailureException const&) {
-    XBT_DEBUG("Caught an HostFailureException");
+  } catch (simgrid::Exception const& e) {
+    XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
+    throw e;
   }
   context->Context::stop();
   ASAN_ONLY(context->asan_stop_ = true);
index 6c3e92a..2edbd1d 100644 (file)
@@ -264,8 +264,9 @@ void RawContext::wrapper(void* arg)
     (*context)();
   } catch (StopRequest const&) {
     XBT_DEBUG("Caught a StopRequest");
-  } catch (simgrid::HostFailureException const&) {
-    XBT_DEBUG("Caught an HostFailureException");
+  } catch (simgrid::Exception const& e) {
+    XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
+    throw e;
   }
   context->Context::stop();
 
index 5c2e86d..92350b5 100644 (file)
@@ -116,16 +116,14 @@ void *ThreadContext::wrapper(void *param)
 
   try {
     (*context)();
-    if (not context->is_maestro()) // really?
-      context->Context::stop();
   } catch (StopRequest const&) {
     XBT_DEBUG("Caught a StopRequest");
     xbt_assert(not context->is_maestro(), "I'm not supposed to be maestro here.");
-  } catch (simgrid::HostFailureException const&) {
-    XBT_DEBUG("Caught an HostFailureException");
+  } catch (simgrid::Exception const& e) {
+    XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
+    throw e;
   }
-  if (not context->is_maestro()) // really?
-    context->Context::stop();
+  context->Context::stop();
 
   // Signal to the caller (normally the maestro) that we have finished:
   context->yield();
index d821c3c..a861b24 100644 (file)
@@ -125,8 +125,9 @@ void UContext::smx_ctx_sysv_wrapper(int i1, int i2)
     (*context)();
   } catch (simgrid::kernel::context::Context::StopRequest const&) {
     XBT_DEBUG("Caught a StopRequest");
-  } catch (simgrid::HostFailureException const&) {
-    XBT_DEBUG("Caught an HostFailureException");
+  } catch (simgrid::Exception const& e) {
+    XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
+    throw e;
   }
   context->Context::stop();
   ASAN_ONLY(context->asan_stop_ = true);
index 8c9e22a..a91c4c8 100644 (file)
@@ -499,8 +499,9 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
   process->suspended_          = false;
   process->exception = nullptr;
 
+  // Forcefully kill the actor if its host is turned off. Not an HostFailureException because you should not survive that
   if (process->host_->is_off())
-    process->throw_exception(std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed")));
+    process->throw_exception(std::make_exception_ptr(simgrid::kernel::context::Context::StopRequest("Host failed")));
 
   /* destroy the blocking synchro if any */
   if (process->waiting_synchro != nullptr) {