multithreaded calee application crashes

43 views
Skip to first unread message

Rosa Lisin

unread,
Mar 4, 2016, 3:05:13 PM3/4/16
to CppWAMP

Hi Emile,
I am trying to create a multithreaded caller/callee applications with the remote procedure returning a deferred outcome (to simulate a time consuming operation). Basiaclly the callee enrolls to provide a procedure, and the caller calls that procedure from 5 threads every 20 seconds. The caller application crashes after several minutes with the following error:
 terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::current_exception_std_exception_wrapper<std::runtime_error> >'
 here is a snippet of the core:
(gdb) up
#11 0x0808dc92 in boost::asio::detail::coro_handler<boost::asio::detail::wrapped_handler<boost::asio::io_service::strand, void (*)(), boost::asio::detail::is_continuation_if_running>, wamp::AsyncResult<wamp::Result> >::operator() (
    this=0xb1a01260, value=...)
    at /usr/local/include/boost/asio/impl/spawn.hpp:53
53        (*coro_)();
(gdb) up
#12 0x0808750e in std::_Function_handler<void (wamp::AsyncResult<wamp::Result>), boost::asio::detail::coro_handler<boost::asio::detail::wrapped_handler<boost::asio::io_service::strand, void (*)(), boost::asio::detail::is_continuation_if_running>, wamp::AsyncResult<wamp::Result> > >::_M_invoke(std::_Any_data const&, wamp::AsyncResult<wamp::Result>) (__functor=..., __args#0=...)
    at /usr/include/c++/4.8/functional:2071
2071 (*_Base::_M_get_pointer(__functor))(
(gdb) 

I am attaching both applications. Please let me know if there is a problem with my implementation.
Thanks,
Rosa
callee.cpp
caller.cpp

Emile Cormier

unread,
Mar 5, 2016, 10:26:20 AM3/5/16
to CppWAMP
Rosa,

There can only be one thread executing the io_service loop used by CoroSession. Try using a separate io_service instance for your worker threads.

Cheers,
Emile

Rosa Lisin

unread,
Mar 10, 2016, 10:46:02 AM3/10/16
to CppWAMP
Thanks a lot!
Reply all
Reply to author
Forward
0 new messages