Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11991: Application crashes when yield/resume an coroutine after handing an exception
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-02-17 08:34:30
#11991: Application crashes when yield/resume an coroutine after handing an
exception
-------------------------+-------------------------------------------------
Reporter: | Owner: chris_kohlhoff
misko.pawel@⦠| Status: new
Type: Bugs | Component: asio
Milestone: To Be | Severity: Problem
Determined | Keywords: asio coroutine windows Visual
Version: Boost | Studio 2015
1.61.0 |
Resolution: |
-------------------------+-------------------------------------------------
Changes (by olli):
* owner: olli => chris_kohlhoff
* component: coroutine => asio
Comment:
You must not install/call an async_result inside a exception handler
(catch-block).
The exception handler might reside on the stack or might removed from the
stack (including the variables) if left. Especially MS is unspecific what
happens under the hood (in contrast to C++-Itanium exception ABI).
A small modification of your code prevents the error (async_result is
allocated outside the exception handler):
{{{
spawn( ios, [&ios]( auto yield ){
bool failed = false;
try{
throw std::runtime_error{ "" };
}catch( ... ){
std::cerr << "[1] " << std::endl;
failed = true;
}
if (failed){
yield_completion_t completion{ yield_context{ yield } };
auto handler = completion.handler;
ios.post( [=]
{
std::this_thread::sleep_for( seconds{ 1 } );
asio_handler_invoke( handler, &handler );
} );
completion.result.get();
std::cerr << "[2] " << std::endl;
}
} );
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11991#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC