Mentioned in a comment in https://casablanca.codeplex.com/workitem/177.
raffaeler wrote Fri at 6:41 AM [x]
Using 2.1.0 here.
I could not even catch the exception with websocket_exception nor "..."
When the receive is ongoing and the close is called, the rest sdk internal code crashes without any chance to catch the exception.
Stack trace of the error:
cpprest120d_2_1.dll!Concurrency::details::_ExceptionHolder::~_ExceptionHolder(void) Unknown
cpprest120d_2_1.dll!Concurrency::details::_ExceptionHolder::`scalar deleting destructor'(unsigned int) Unknown
cpprest120d_2_1.dll!std::_Ref_count_obj<struct Concurrency::details::_ExceptionHolder>::_Destroy(void) Unknown
WebsocketsTesterCpp.exe!std::_Ref_count_base::_Decref() Line 118 C++
WebsocketsTesterCpp.exe!std::_Ptr_base<Concurrency::details::_ExceptionHolder>::_Decref() Line 344 C++
WebsocketsTesterCpp.exe!std::shared_ptr<Concurrency::details::_ExceptionHolder>::~shared_ptr<Concurrency::details::_ExceptionHolder>() Line 611 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl_base::~_Task_impl_base() Line 1677 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::~_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >() Line 2367 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::`scalar deleting destructor'(unsigned int) C++
WebsocketsTesterCpp.exe!std::_Ref_count_obj<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Destroy() Line 944 C++
WebsocketsTesterCpp.exe!std::_Ref_count_base::_Decref() Line 118 C++
WebsocketsTesterCpp.exe!std::_Ptr_base<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Decref() Line 344 C++
WebsocketsTesterCpp.exe!std::shared_ptr<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~shared_ptr<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >() Line 611 C++
WebsocketsTesterCpp.exe!Concurrency::details::_PPLTaskHandle<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>,Concurrency::details::_ContinuationTaskHandleBase>::~_PPLTaskHandle<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>,Concurrency::details::_ContinuationTaskHandleBase>() Line 1588 C++
WebsocketsTesterCpp.exe!Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>::~_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>() Line 3769 C++
WebsocketsTesterCpp.exe!Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>::`scalar deleting destructor'(unsigned int) C++
msvcr120d.dll!0fbc72bc() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr120d.dll]
msvcr120d.dll!0fbfe801() Unknown
msvcr120d.dll!0fbc7e8a() Unknown
msvcr120d.dll!0fbd75b3() Unknown
msvcr120d.dll!0fbf9ac1() Unknown
msvcr120d.dll!0fbd4257() Unknown
msvcr120d.dll!0fbd4123() Unknown
msvcr120d.dll!0fbd2bae() Unknown
msvcr120d.dll!0fc00f94() Unknown
kernel32.dll!76b0919f() Unknown
ntdll.dll!7718a22b() Unknown
ntdll.dll!7718a201() Unknown
Suggestions?
Comments: Hi raffaeler, As I understand it, your code looks something like ``` void StartReceiving() { client->receive().then([]() { ... }).then([]() { ... StartReceiving(); }); } ``` Note that calls to ```.then()``` will return immediately and won't propagate exceptions that occur inside the lambda. If you want to capture those exceptions, you will need to call either ```.wait()``` or ```.get()```. Since you don't want to recurse indefinitely (which would happen by just calling ```.get()``` here), you should add another trailing ```.then()``` that internally captures the errors (like you have in your first continuation). ``` void StartReceiving() { client->receive().then([]() { ... }).then([]() { ... StartReceiving(); }).then([](task<void> t) { try { t.get(); } catch (...) { /* Make noise here */ } }); } ``` If this doesn't solve your issue, could you attach a full source file which reproduces the behavior? Thanks, roschuma
raffaeler wrote Fri at 6:41 AM [x]
Using 2.1.0 here.
I could not even catch the exception with websocket_exception nor "..."
When the receive is ongoing and the close is called, the rest sdk internal code crashes without any chance to catch the exception.
Stack trace of the error:
cpprest120d_2_1.dll!Concurrency::details::_ExceptionHolder::~_ExceptionHolder(void) Unknown
cpprest120d_2_1.dll!Concurrency::details::_ExceptionHolder::`scalar deleting destructor'(unsigned int) Unknown
cpprest120d_2_1.dll!std::_Ref_count_obj<struct Concurrency::details::_ExceptionHolder>::_Destroy(void) Unknown
WebsocketsTesterCpp.exe!std::_Ref_count_base::_Decref() Line 118 C++
WebsocketsTesterCpp.exe!std::_Ptr_base<Concurrency::details::_ExceptionHolder>::_Decref() Line 344 C++
WebsocketsTesterCpp.exe!std::shared_ptr<Concurrency::details::_ExceptionHolder>::~shared_ptr<Concurrency::details::_ExceptionHolder>() Line 611 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl_base::~_Task_impl_base() Line 1677 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::~_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >() Line 2367 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::`scalar deleting destructor'(unsigned int) C++
WebsocketsTesterCpp.exe!std::_Ref_count_obj<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Destroy() Line 944 C++
WebsocketsTesterCpp.exe!std::_Ref_count_base::_Decref() Line 118 C++
WebsocketsTesterCpp.exe!std::_Ptr_base<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Decref() Line 344 C++
WebsocketsTesterCpp.exe!std::shared_ptr<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~shared_ptr<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >() Line 611 C++
WebsocketsTesterCpp.exe!Concurrency::details::_PPLTaskHandle<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>,Concurrency::details::_ContinuationTaskHandleBase>::~_PPLTaskHandle<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>,Concurrency::details::_ContinuationTaskHandleBase>() Line 1588 C++
WebsocketsTesterCpp.exe!Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>::~_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>() Line 3769 C++
WebsocketsTesterCpp.exe!Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>::`scalar deleting destructor'(unsigned int) C++
msvcr120d.dll!0fbc72bc() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr120d.dll]
msvcr120d.dll!0fbfe801() Unknown
msvcr120d.dll!0fbc7e8a() Unknown
msvcr120d.dll!0fbd75b3() Unknown
msvcr120d.dll!0fbf9ac1() Unknown
msvcr120d.dll!0fbd4257() Unknown
msvcr120d.dll!0fbd4123() Unknown
msvcr120d.dll!0fbd2bae() Unknown
msvcr120d.dll!0fc00f94() Unknown
kernel32.dll!76b0919f() Unknown
ntdll.dll!7718a22b() Unknown
ntdll.dll!7718a201() Unknown
Suggestions?
Comments: Hi raffaeler, As I understand it, your code looks something like ``` void StartReceiving() { client->receive().then([]() { ... }).then([]() { ... StartReceiving(); }); } ``` Note that calls to ```.then()``` will return immediately and won't propagate exceptions that occur inside the lambda. If you want to capture those exceptions, you will need to call either ```.wait()``` or ```.get()```. Since you don't want to recurse indefinitely (which would happen by just calling ```.get()``` here), you should add another trailing ```.then()``` that internally captures the errors (like you have in your first continuation). ``` void StartReceiving() { client->receive().then([]() { ... }).then([]() { ... StartReceiving(); }).then([](task<void> t) { try { t.get(); } catch (...) { /* Make noise here */ } }); } ``` If this doesn't solve your issue, could you attach a full source file which reproduces the behavior? Thanks, roschuma