Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename StopRequest into ForcefulKillException to contribute to #325
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 4 Mar 2019 22:01:36 +0000 (23:01 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 4 Mar 2019 22:02:15 +0000 (23:02 +0100)
16 files changed:
.appveyor.yml
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg_host.cpp
src/bindings/java/jmsg_process.cpp
src/bindings/java/jmsg_task.cpp
src/bindings/java/jmsg_vm.cpp
src/bindings/python/simgrid_python.cpp
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp
src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextSwapped.cpp
src/kernel/context/ContextThread.cpp
src/kernel/context/ContextUnix.cpp
src/simix/ActorImpl.cpp
src/xbt/exception.cpp

index cd7a096..7ef6a30 100644 (file)
@@ -47,7 +47,7 @@ build_script:
 - mingw32-make.exe VERBOSE=1 java-all python-bindings # Only the Java and Python parts
 - ctest --output-on-failure -R java
 # Don't test python, as pybind11 seems too complex for mingw for now (mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1)
 - mingw32-make.exe VERBOSE=1 java-all python-bindings # Only the Java and Python parts
 - ctest --output-on-failure -R java
 # Don't test python, as pybind11 seems too complex for mingw for now (mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1)
-# The observed failure is around the StopRequest exception, that seems badly catched somehow.
+# The observed failure is around the ForcefulKill exception, that seems badly catched somehow.
 # - ctest --output-on-failure -R python
 
 artifacts:
 # - ctest --output-on-failure -R python
 
 artifacts:
index a98c6bd..17a86a4 100644 (file)
@@ -277,7 +277,7 @@ static void run_jprocess(JNIEnv *env, jobject jprocess)
     env->ExceptionClear();
     XBT_ATTRIB_UNUSED jint error = __java_vm->DetachCurrentThread();
     xbt_assert(error == JNI_OK, "Cannot detach failing thread");
     env->ExceptionClear();
     XBT_ATTRIB_UNUSED jint error = __java_vm->DetachCurrentThread();
     xbt_assert(error == JNI_OK, "Cannot detach failing thread");
-    simgrid::kernel::context::StopRequest::do_throw();
+    simgrid::kernel::context::ForcefulKillException::do_throw();
   }
 }
 
   }
 }
 
index eb9938c..63d9099 100644 (file)
@@ -142,7 +142,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_on(JNIEnv *env, jobject jhost)
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_off(JNIEnv *env, jobject jhost) {
   msg_host_t host = jhost_get_native(env, jhost);
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_off(JNIEnv *env, jobject jhost) {
   msg_host_t host = jhost_get_native(env, jhost);
-  if (not simgrid::kernel::context::StopRequest::try_n_catch([host]() { MSG_host_off(host); }))
+  if (not simgrid::kernel::context::ForcefulKillException::try_n_catch([host]() { MSG_host_off(host); }))
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Host turned off");
 }
 
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Host turned off");
 }
 
index c20b3a4..0d0866c 100644 (file)
@@ -229,7 +229,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cl
  {
   double time =  ((double)jmillis) / 1000 + ((double)jnanos) / 1000000000;
   msg_error_t rv = MSG_OK;
  {
   double time =  ((double)jmillis) / 1000 + ((double)jnanos) / 1000000000;
   msg_error_t rv = MSG_OK;
-  if (not simgrid::kernel::context::StopRequest::try_n_catch(
+  if (not simgrid::kernel::context::ForcefulKillException::try_n_catch(
           [&time]() { simgrid::s4u::this_actor::sleep_for(time); })) {
     rv = MSG_HOST_FAILURE;
   }
           [&time]() { simgrid::s4u::this_actor::sleep_for(time); })) {
     rv = MSG_HOST_FAILURE;
   }
@@ -241,7 +241,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cl
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess, jdouble jseconds)
 {
   msg_error_t rv = MSG_OK;
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess, jdouble jseconds)
 {
   msg_error_t rv = MSG_OK;
-  if (not simgrid::kernel::context::StopRequest::try_n_catch(
+  if (not simgrid::kernel::context::ForcefulKillException::try_n_catch(
           [&jseconds]() { simgrid::s4u::this_actor::sleep_for((double)jseconds); })) {
     rv = MSG_HOST_FAILURE;
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
           [&jseconds]() { simgrid::s4u::this_actor::sleep_for((double)jseconds); })) {
     rv = MSG_HOST_FAILURE;
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
@@ -262,7 +262,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill(JNIEnv * env, jobject j
     jxbt_throw_notbound(env, "process", jprocess);
     return;
   }
     jxbt_throw_notbound(env, "process", jprocess);
     return;
   }
-  if (not simgrid::kernel::context::StopRequest::try_n_catch([&process]() { MSG_process_kill(process); })) {
+  if (not simgrid::kernel::context::ForcefulKillException::try_n_catch([&process]() { MSG_process_kill(process); })) {
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
   }
 }
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
   }
 }
index 77edf00..67b88f2 100644 (file)
@@ -127,7 +127,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_execute(JNIEnv * env, jobject j
     return;
   }
   msg_error_t rv;
     return;
   }
   msg_error_t rv;
-  if (not simgrid::kernel::context::StopRequest::try_n_catch([&rv, &task]() { rv = MSG_task_execute(task); })) {
+  if (not simgrid::kernel::context::ForcefulKillException::try_n_catch(
+          [&rv, &task]() { rv = MSG_task_execute(task); })) {
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
   }
 
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
   }
 
@@ -286,7 +287,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv* env, jclass
 
   const char *alias = env->GetStringUTFChars(jalias, 0);
   msg_error_t rv;
 
   const char *alias = env->GetStringUTFChars(jalias, 0);
   msg_error_t rv;
-  if (not simgrid::kernel::context::StopRequest::try_n_catch([&rv, &task, &alias, &jtimeout]() {
+  if (not simgrid::kernel::context::ForcefulKillException::try_n_catch([&rv, &task, &alias, &jtimeout]() {
         rv = MSG_task_receive_ext(&task, alias, (double)jtimeout, /*host*/ nullptr);
       })) {
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
         rv = MSG_task_receive_ext(&task, alias, (double)jtimeout, /*host*/ nullptr);
       })) {
     jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
index 18afc0a..7102bb4 100644 (file)
@@ -151,7 +151,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeMigration(JNIEnv* env, jobj
 {
   msg_vm_t vm = jvm_get_native(env,jvm);
   msg_host_t host = jhost_get_native(env, jhost);
 {
   msg_vm_t vm = jvm_get_native(env,jvm);
   msg_host_t host = jhost_get_native(env, jhost);
-  if (not simgrid::kernel::context::StopRequest::try_n_catch([&vm, &host]() { MSG_vm_migrate(vm, host); })) {
+  if (not simgrid::kernel::context::ForcefulKillException::try_n_catch([&vm, &host]() { MSG_vm_migrate(vm, host); })) {
     XBT_VERB("Caught exception during migration");
     jxbt_throw_host_failure(env, "during migration");
   }
     XBT_VERB("Caught exception during migration");
     jxbt_throw_host_failure(env, "during migration");
   }
index eb74563..f9074bf 100644 (file)
@@ -56,7 +56,8 @@ PYBIND11_MODULE(simgrid, m)
   m.attr("simgrid_version") = simgrid_version;
 
   // Internal exception used to kill actors and sweep the RAII chimney (free objects living on the stack)
   m.attr("simgrid_version") = simgrid_version;
 
   // Internal exception used to kill actors and sweep the RAII chimney (free objects living on the stack)
-  py::object pyStopRequestEx = py::register_exception<simgrid::kernel::context::StopRequest>(m, "ActorKilled");
+  py::object pyForcefulKillEx =
+      py::register_exception<simgrid::kernel::context::ForcefulKillException>(m, "ActorKilled");
 
   /* this_actor namespace */
   void (*sleep_for_fun)(double) = &simgrid::s4u::this_actor::sleep_for; // pick the right overload
 
   /* this_actor namespace */
   void (*sleep_for_fun)(double) = &simgrid::s4u::this_actor::sleep_for; // pick the right overload
@@ -116,10 +117,10 @@ PYBIND11_MODULE(simgrid, m)
            ":cpp:func:`simgrid::s4u::Engine::load_deployment()`")
       .def("run", &Engine::run, "Run the simulation")
       .def("register_actor",
            ":cpp:func:`simgrid::s4u::Engine::load_deployment()`")
       .def("run", &Engine::run, "Run the simulation")
       .def("register_actor",
-           [pyStopRequestEx](Engine*, const std::string& name, py::object fun_or_class) {
+           [pyForcefulKillEx](Engine*, const std::string& name, py::object fun_or_class) {
              simgrid::simix::register_function(
              simgrid::simix::register_function(
-                 name, [pyStopRequestEx, fun_or_class](std::vector<std::string> args) -> simgrid::simix::ActorCode {
-                   return [pyStopRequestEx, fun_or_class, args]() {
+                 name, [pyForcefulKillEx, fun_or_class](std::vector<std::string> args) -> simgrid::simix::ActorCode {
+                   return [pyForcefulKillEx, fun_or_class, args]() {
                      try {
                        /* Convert the std::vector into a py::tuple */
                        py::tuple params(args.size() - 1);
                      try {
                        /* Convert the std::vector into a py::tuple */
                        py::tuple params(args.size() - 1);
@@ -132,9 +133,9 @@ PYBIND11_MODULE(simgrid, m)
                        if (py::isinstance<py::function>(res))
                          res();
                      } catch (py::error_already_set& ex) {
                        if (py::isinstance<py::function>(res))
                          res();
                      } catch (py::error_already_set& ex) {
-                       if (ex.matches(pyStopRequestEx)) {
+                       if (ex.matches(pyForcefulKillEx)) {
                          XBT_VERB("Actor killed");
                          XBT_VERB("Actor killed");
-                         /* Stop here that StopRequest exception which was meant to free the RAII stuff on the stack */
+                         /* Stop here that ForcefulKill exception which was meant to free the RAII stuff on the stack */
                        } else {
                          throw;
                        }
                        } else {
                          throw;
                        }
@@ -176,16 +177,16 @@ PYBIND11_MODULE(simgrid, m)
                                             "application, see :ref:`class s4u::Actor <API_s4u_Actor>`")
 
       .def("create",
                                             "application, see :ref:`class s4u::Actor <API_s4u_Actor>`")
 
       .def("create",
-           [pyStopRequestEx](py::str name, py::object host, py::object fun, py::args args) {
+           [pyForcefulKillEx](py::str name, py::object host, py::object fun, py::args args) {
 
 
-             return simgrid::s4u::Actor::create(name, host.cast<Host*>(), [fun, args, pyStopRequestEx]() {
+             return simgrid::s4u::Actor::create(name, host.cast<Host*>(), [fun, args, pyForcefulKillEx]() {
 
                try {
                  fun(*args);
                } catch (py::error_already_set& ex) {
 
                try {
                  fun(*args);
                } catch (py::error_already_set& ex) {
-                 if (ex.matches(pyStopRequestEx)) {
+                 if (ex.matches(pyForcefulKillEx)) {
                    XBT_VERB("Actor killed");
                    XBT_VERB("Actor killed");
-                   /* Stop here that StopRequest exception which was meant to free the RAII stuff on the stack */
+                   /* Stop here that ForcefulKill exception which was meant to free the RAII stuff on the stack */
                  } else {
                    throw;
                  }
                  } else {
                    throw;
                  }
index 0471a5c..51b492a 100644 (file)
@@ -112,21 +112,21 @@ void Context::stop()
 
 AttachContext::~AttachContext() = default;
 
 
 AttachContext::~AttachContext() = default;
 
-StopRequest::~StopRequest() = default;
+ForcefulKillException::~ForcefulKillException() = default;
 
 
-void StopRequest::do_throw()
+void ForcefulKillException::do_throw()
 {
 {
-  throw StopRequest();
+  throw ForcefulKillException();
 }
 
 }
 
-bool StopRequest::try_n_catch(std::function<void(void)> try_block)
+bool ForcefulKillException::try_n_catch(std::function<void(void)> try_block)
 {
   bool res;
   try {
     try_block();
     res = true;
 {
   bool res;
   try {
     try_block();
     res = true;
-  } catch (StopRequest const&) {
-    XBT_DEBUG("Caught a StopRequest");
+  } catch (ForcefulKillException const&) {
+    XBT_DEBUG("Caught a ForcefulKillException");
     res = false;
   }
   return res;
     res = false;
   }
   return res;
index 7bacdcf..cff4dbe 100644 (file)
@@ -86,21 +86,21 @@ public:
   virtual void attach_stop() = 0;
 };
 
   virtual void attach_stop() = 0;
 };
 
-class XBT_PUBLIC StopRequest {
-  /** @brief Exception launched to kill an actor; do not block it!
+class XBT_PUBLIC ForcefulKillException {
+  /** @brief Exception launched to kill an actor; DO NOT BLOCK IT!
    *
    * This exception is thrown whenever the actor's host is turned off. The actor stack is properly unwinded to release
    * all objects allocated on the stack (RAII powa).
    *
    * You may want to catch this exception to perform some extra cleanups in your simulation, but YOUR ACTORS MUST NEVER
    *
    * This exception is thrown whenever the actor's host is turned off. The actor stack is properly unwinded to release
    * all objects allocated on the stack (RAII powa).
    *
    * You may want to catch this exception to perform some extra cleanups in your simulation, but YOUR ACTORS MUST NEVER
-   * SURVIVE a StopRequest, or your simulation will segfault.
+   * SURVIVE a ForcefulKillException, or your simulation will segfault.
    *
    * @verbatim
    * void* payload = malloc(512);
    *
    * try {
    *   simgrid::s4u::this_actor::execute(100000);
    *
    * @verbatim
    * void* payload = malloc(512);
    *
    * try {
    *   simgrid::s4u::this_actor::execute(100000);
-   * } catch (simgrid::kernel::context::StopRequest& e) { // oops, my host just turned off
+   * } catch (simgrid::kernel::context::ForcefulKillException& e) { // oops, my host just turned off
    *   free(malloc);
    *   throw; // I shall never survive on an host that was switched off
    * }
    *   free(malloc);
    *   throw; // I shall never survive on an host that was switched off
    * }
@@ -110,9 +110,11 @@ class XBT_PUBLIC StopRequest {
    * Otherwise, users may accidentally catch it with a try {} catch (std::exception)
    */
 public:
    * Otherwise, users may accidentally catch it with a try {} catch (std::exception)
    */
 public:
-  StopRequest() = default;
-  explicit StopRequest(const std::string& msg) : msg_(std::string("Actor killed (") + msg + std::string(").")) {}
-  ~StopRequest();
+  ForcefulKillException() = default;
+  explicit ForcefulKillException(const std::string& msg) : msg_(std::string("Actor killed (") + msg + std::string(")."))
+  {
+  }
+  ~ForcefulKillException();
   const char* what() const noexcept { return msg_.c_str(); }
 
   static void do_throw();
   const char* what() const noexcept { return msg_.c_str(); }
 
   static void do_throw();
index b1deb29..4298641 100644 (file)
@@ -69,8 +69,8 @@ void BoostContext::wrapper(BoostContext::arg_type arg)
   try {
     (*context)();
     context->Context::stop();
   try {
     (*context)();
     context->Context::stop();
-  } catch (StopRequest const&) {
-    XBT_DEBUG("Caught a StopRequest");
+  } catch (ForcefulKillException const&) {
+    XBT_DEBUG("Caught a ForcefulKillException");
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
index e651a46..2f0165f 100644 (file)
@@ -211,8 +211,8 @@ void RawContext::wrapper(void* arg)
   try {
     (*context)();
     context->Context::stop();
   try {
     (*context)();
     context->Context::stop();
-  } catch (StopRequest const&) {
-    XBT_DEBUG("Caught a StopRequest");
+  } catch (ForcefulKillException const&) {
+    XBT_DEBUG("Caught a ForcefulKillException");
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
index 7a2de5b..1147740 100644 (file)
@@ -147,7 +147,7 @@ void SwappedContext::stop()
 {
   Context::stop();
   /* We must cut the actor execution using an exception to properly free the C++ RAII variables */
 {
   Context::stop();
   /* We must cut the actor execution using an exception to properly free the C++ RAII variables */
-  throw StopRequest();
+  throw ForcefulKillException();
 }
 
 /** Maestro wants to run all ready actors */
 }
 
 /** Maestro wants to run all ready actors */
index a164339..f03413b 100644 (file)
@@ -103,9 +103,9 @@ void *ThreadContext::wrapper(void *param)
       context->Context::stop();
       context->stop_hook();
     }
       context->Context::stop();
       context->stop_hook();
     }
-  } catch (StopRequest const&) {
-    XBT_DEBUG("Caught a StopRequest in Thread::wrapper");
-    xbt_assert(not context->is_maestro(), "Maestro shall not receive StopRequests, even when detached.");
+  } catch (ForcefulKillException const&) {
+    XBT_DEBUG("Caught a ForcefulKillException in Thread::wrapper");
+    xbt_assert(not context->is_maestro(), "Maestro shall not receive ForcefulKillExceptions, even when detached.");
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
@@ -148,7 +148,7 @@ void ThreadContext::stop()
 {
   Context::stop();
   stop_hook();
 {
   Context::stop();
   stop_hook();
-  throw StopRequest();
+  throw ForcefulKillException();
 }
 
 void ThreadContext::suspend()
 }
 
 void ThreadContext::suspend()
index ad79b5e..2d6fcce 100644 (file)
@@ -41,8 +41,8 @@ static void smx_ctx_wrapper(int i1, int i2)
   try {
     (*context)();
     context->Context::stop();
   try {
     (*context)();
     context->Context::stop();
-  } catch (simgrid::kernel::context::StopRequest const&) {
-    XBT_DEBUG("Caught a StopRequest");
+  } catch (simgrid::kernel::context::ForcefulKillException const&) {
+    XBT_DEBUG("Caught a ForcefulKillException");
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
index 1b92ac6..bcbe884 100644 (file)
@@ -164,7 +164,7 @@ void ActorImpl::exit()
 
   // Forcefully kill the actor if its host is turned off. Not a HostFailureException because you should not survive that
   if (not host_->is_on())
 
   // Forcefully kill the actor if its host is turned off. Not a HostFailureException because you should not survive that
   if (not host_->is_on())
-    this->throw_exception(std::make_exception_ptr(simgrid::kernel::context::StopRequest("host failed")));
+    this->throw_exception(std::make_exception_ptr(simgrid::kernel::context::ForcefulKillException("host failed")));
 
   /* destroy the blocking synchro if any */
   if (waiting_synchro != nullptr) {
 
   /* destroy the blocking synchro if any */
   if (waiting_synchro != nullptr) {
@@ -273,7 +273,7 @@ void ActorImpl::yield()
   if (context_->iwannadie) {
 
     XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
   if (context_->iwannadie) {
 
     XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
-    // throw simgrid::kernel::context::StopRequest(); Does not seem to properly kill the actor
+    // throw simgrid::kernel::context::ForcefulKillException(); Does not seem to properly kill the actor
     context_->stop();
     THROW_IMPOSSIBLE;
   }
     context_->stop();
     THROW_IMPOSSIBLE;
   }
index eb4878a..a87ac86 100644 (file)
@@ -145,8 +145,9 @@ static void handler()
     std::abort();
   }
 
     std::abort();
   }
 
-  catch (simgrid::kernel::context::StopRequest& e) {
-    XBT_ERROR("Received a StopRequest at the top-level exception handler. Maybe a Java->C++ call that is not protected "
+  catch (simgrid::kernel::context::ForcefulKillException& e) {
+    XBT_ERROR("Received a ForcefulKillException at the top-level exception handler. Maybe a Java->C++ call that is not "
+              "protected "
               "in a try/catch?");
     show_backtrace(bt);
   }
               "in a try/catch?");
     show_backtrace(bt);
   }