[Boost-bugs] [Boost C++ Libraries] #11991: Application crashes when yield/resume an coroutine after handing an exception

Subject: [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-16 19:03:21


#11991: Application crashes when yield/resume an coroutine after handing an
exception
-------------------------------------------------+-------------------------
 Reporter: misko.pawel@… | Owner: olli
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: coroutine
  Version: Boost 1.61.0 | Severity: Problem
 Keywords: asio coroutine windows Visual |
  Studio 2015 |
-------------------------------------------------+-------------------------
 {{{
 #include <iostream>
 #include <stdexcept>
 #include <thread>
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/spawn.hpp>

 int main()
 {
     using namespace boost::asio;
     using std::chrono::seconds;
     using yield_completion_t = detail::async_result_init< yield_context,
 void () >;

     io_service ios;

     spawn( ios, [&ios]( auto yield )
     {
         try
         {
             throw std::runtime_error{ "" };
         }
         catch( ... )
         {
             std::cerr << "[1] " << std::endl;

             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;
         }

     } );

     // needs more than one thread
     std::thread t{ [&]{ ios.run(); } };

     ios.run();
     t.join();

     return 0;
 }
 }}}
 Prints:
 {{{
 [1]
 [2]
 }}}

 and crashes.

 Debugger points to `_FindAndUnlinkFrame` (inside `trnsctrl.cpp` file):
 `pCurFrameInfo->pNext` causes AV because pCurFrameInfo is null.

 VS 2015, Win7

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11991>
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