From 4669e551b9e717619bca0dc9ddbee44dc17bedbd Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Mon, 1 Aug 2016 17:31:03 +0200 Subject: [PATCH] assign current context in control_block destructor - current context has to be assigned to priv. member variable 'other' - otherwise stack unwinding will jump to an invalid context --- include/boost/coroutine2/detail/pull_control_block_ecv1.ipp | 3 +++ include/boost/coroutine2/detail/push_control_block_ecv1.ipp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/include/boost/coroutine2/detail/pull_control_block_ecv1.ipp b/include/boost/coroutine2/detail/pull_control_block_ecv1.ipp index 5edd438..eb2ae27 100644 --- a/include/boost/coroutine2/detail/pull_control_block_ecv1.ipp +++ b/include/boost/coroutine2/detail/pull_control_block_ecv1.ipp @@ -125,6 +125,7 @@ pull_coroutine< T >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } // destroy data if it set @@ -273,6 +274,7 @@ pull_coroutine< T & >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } } @@ -399,6 +401,7 @@ pull_coroutine< void >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } } diff --git a/include/boost/coroutine2/detail/push_control_block_ecv1.ipp b/include/boost/coroutine2/detail/push_control_block_ecv1.ipp index e5546d1..cc9622d 100644 --- a/include/boost/coroutine2/detail/push_control_block_ecv1.ipp +++ b/include/boost/coroutine2/detail/push_control_block_ecv1.ipp @@ -130,6 +130,7 @@ push_coroutine< T >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } } @@ -271,6 +272,7 @@ push_coroutine< T & >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } } @@ -396,6 +398,7 @@ push_coroutine< void >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } }