From: Arnaud Giersch Date: Tue, 22 Jan 2019 19:48:43 +0000 (+0100) Subject: Avoid to call Context::stop() again when a StopRequest was thrown. X-Git-Tag: v3_22~500^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1fa0907fa303867668e0a19ffebb91d4bc4920ad?ds=sidebyside Avoid to call Context::stop() again when a StopRequest was thrown. It's already called just before the exception is thrown by the stop() method (SwappedContext or ThreadContext). Asan likes it better when it's called before throwing the exception. --- diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index 1bddeb1307..6153c41878 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -70,13 +70,13 @@ void BoostContext::wrapper(BoostContext::arg_type arg) #endif try { (*context)(); + context->Context::stop(); } catch (StopRequest const&) { XBT_DEBUG("Caught a StopRequest"); } catch (simgrid::Exception const& e) { XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get()); throw; } - context->Context::stop(); ASAN_ONLY(context->asan_stop_ = true); context->suspend(); } diff --git a/src/kernel/context/ContextRaw.cpp b/src/kernel/context/ContextRaw.cpp index c7a0a1c5ff..84d742c45c 100644 --- a/src/kernel/context/ContextRaw.cpp +++ b/src/kernel/context/ContextRaw.cpp @@ -212,14 +212,13 @@ void RawContext::wrapper(void* arg) ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_); try { (*context)(); + context->Context::stop(); } catch (StopRequest const&) { XBT_DEBUG("Caught a StopRequest"); } catch (simgrid::Exception const& e) { XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get()); throw; } - context->Context::stop(); - ASAN_ONLY(context->asan_stop_ = true); context->suspend(); } diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index 2037673a52..205e1867da 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -100,6 +100,8 @@ void *ThreadContext::wrapper(void *param) try { (*context)(); + if (not context->is_maestro()) // Just in case somebody detached maestro + context->Context::stop(); } catch (StopRequest const&) { XBT_DEBUG("Caught a StopRequest"); xbt_assert(not context->is_maestro(), "Maestro shall not receive StopRequests, even when detached."); @@ -107,9 +109,6 @@ void *ThreadContext::wrapper(void *param) XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get()); throw; } - if (not context->is_maestro()) // Just in case somebody detached maestro - context->Context::stop(); - // Signal to the caller (normally the maestro) that we have finished: context->yield(); diff --git a/src/kernel/context/ContextUnix.cpp b/src/kernel/context/ContextUnix.cpp index 92d92715ce..88d4710956 100644 --- a/src/kernel/context/ContextUnix.cpp +++ b/src/kernel/context/ContextUnix.cpp @@ -40,13 +40,13 @@ static void smx_ctx_wrapper(int i1, int i2) ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_); try { (*context)(); + context->Context::stop(); } catch (simgrid::kernel::context::Context::StopRequest const&) { XBT_DEBUG("Caught a StopRequest"); } catch (simgrid::Exception const& e) { XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get()); throw; } - context->Context::stop(); ASAN_ONLY(context->asan_stop_ = true); context->suspend(); }