{"action":"created","issue":{"url":"https://api.github.com/repos/Corvusoft/restbed/issues/110","repository_url":"https://api.github.com/repos/Corvusoft/restbed","labels_url":"https://api.github.com/repos/Corvusoft/restbed/issues/110/labels{/name}","comments_url":"https://api.github.com/repos/Corvusoft/restbed/issues/110/comments","events_url":"https://api.github.com/repos/Corvusoft/restbed/issues/110/events","html_url":"https://github.com/Corvusoft/restbed/issues/110","id":160943886,"number":110,"title":"ASIO crashing when client closes connection... sometimes.","user":{"login":"terrymah","id":203638,"avatar_url":"https://avatars.githubusercontent.com/u/203638?v=3","gravatar_id":"","url":"https://api.github.com/users/terrymah","html_url":"https://github.com/terrymah","followers_url":"https://api.github.com/users/terrymah/followers","following_url":"https://api.github.com/users/terrymah/following{/other_user}","gists_url":"https://api.github.com/users/terrymah/gists{/gist_id}","starred_url":"https://api.github.com/users/terrymah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terrymah/subscriptions","organizations_url":"https://api.github.com/users/terrymah/orgs","repos_url":"https://api.github.com/users/terrymah/repos","events_url":"https://api.github.com/users/terrymah/events{/privacy}","received_events_url":"https://api.github.com/users/terrymah/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Corvusoft/restbed/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-06-17T18:05:37Z","updated_at":"2016-06-18T00:49:12Z","closed_at":null,"body":"I'm not sure you'll be able to help here, because this isn't something you can easily repro. I have a complex server which \"streams\" search results, via yield.\r\n\r\nThe issue is I have a misbehaving client, which disconnects (closes the socket) frequently. This causes crashes on the server side.\r\n\r\nI know about session->is_open, and that helps a bit, but there still appears to be a timing issue where the session can be closed under me and I get a crash. For example, look at this callstack:\r\n\r\n```\r\n0:001> kn\r\n # ChildEBP RetAddr  \r\n00 (Inline) -------- search!asio::mutable_buffer::{ctor} [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\buffer.hpp @ 101]\r\n01 (Inline) -------- search!asio::buffer [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\buffer.hpp @ 784]\r\n02 023deacc 002f07f0 search!restbed::detail::SocketImpl::write+0x1e9 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\socket_impl.cpp @ 170]\r\n03 023deb40 002f0699 search!restbed::Session::yield+0x120 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\session.cpp @ 194]\r\n04 023deb70 002d630d search!restbed::Session::yield+0x49 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\session.cpp @ 209]\r\n05 023dec94 002dc93c search!<lambda_4c3ad2736744fe3059fa0343f25ff7f6>::operator()+0x1ad [c:\\projects\\femarmis\\src\\search\\rest.cpp @ 473]\r\n06 (Inline) -------- search!std::_Invoker_functor::_Call+0x17 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1408]\r\n07 (Inline) -------- search!std::invoke+0x17 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n08 (Inline) -------- search!std::_Invoke_ret+0x17 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1501]\r\n09 023decc0 002e21c2 search!std::_Func_impl<<lambda_4c3ad2736744fe3059fa0343f25ff7f6>,std::allocator<int>,bool,boost::property_tree::basic_ptree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >::_Do_call+0x1c [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 211]\r\n0a 023dece0 002e1217 search!std::_Func_class<bool,boost::property_tree::basic_ptree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >::operator()+0x42 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 275]\r\n0b 023deff0 0029ab90 search!<lambda_7f37dd1647de03503328c5e661a73de8>::operator()+0x9c7 [c:\\projects\\femarmis\\src\\search\\search.cpp @ 104]\r\n0c (Inline) -------- search!std::_Func_class<bool,FaceInfo const &>::operator()+0x1e [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 275]\r\n0d 023df050 002e066a search!LocalDataSource::ForEachFace+0x140 [c:\\projects\\femarmis\\src\\search\\localdatasource.cpp @ 477]\r\n0e 023df2d4 002d6088 search!FindFacesTree+0x4ba [c:\\projects\\femarmis\\src\\search\\search.cpp @ 110]\r\n0f 023df39c 002d7f3a search!GET_user_id_search2+0x308 [c:\\projects\\femarmis\\src\\search\\rest.cpp @ 477]\r\n10 023df3d8 002dc7ff search!<lambda_1208e75997f7de7e3aa17fc51057a1f9>::operator()+0xba [c:\\projects\\femarmis\\src\\search\\rest.cpp @ 645]\r\n11 (Inline) -------- search!std::_Invoker_functor::_Call+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1408]\r\n12 (Inline) -------- search!std::invoke+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n13 (Inline) -------- search!std::_Invoke_ret+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1494]\r\n14 023df3f0 002eec71 search!std::_Func_impl<<lambda_1208e75997f7de7e3aa17fc51057a1f9>,std::allocator<int>,void,std::shared_ptr<restbed::Session> >::_Do_call+0x2f [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 211]\r\n15 023df414 00312c62 search!std::_Func_class<void,std::shared_ptr<restbed::Session> >::operator()+0x41 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 275]\r\n16 023df4c4 0031418c search!<lambda_4bd0ef0d31035a1e39bd7ee2d4c96024>::operator()+0x172 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\service_impl.cpp @ 501]\r\n17 (Inline) -------- search!std::_Invoker_functor::_Call+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1408]\r\n18 (Inline) -------- search!std::invoke+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n19 (Inline) -------- search!std::_Invoke_ret+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1494]\r\n1a 023df4dc 002eec71 search!std::_Func_impl<<lambda_4bd0ef0d31035a1e39bd7ee2d4c96024>,std::allocator<int>,void,std::shared_ptr<restbed::Session> >::_Do_call+0x2c [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 211]\r\n1b 023df500 0031adc7 search!std::_Func_class<void,std::shared_ptr<restbed::Session> >::operator()+0x41 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 275]\r\n1c 023df57c 00312a8a search!restbed::detail::rule_engine+0x157 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\rule_engine_impl.hpp @ 52]\r\n1d 023df5e8 00313040 search!<lambda_2b5c0973859361aa480f4e909115d50b>::operator()+0xba [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\service_impl.cpp @ 478]\r\n1e 023df668 003141cc search!<lambda_e1cced59481f0ecb647ba0cb19582a2c>::operator()+0x1b0 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\service_impl.cpp @ 512]\r\n1f (Inline) -------- search!std::_Invoker_functor::_Call+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1408]\r\n20 (Inline) -------- search!std::invoke+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n21 (Inline) -------- search!std::_Invoke_ret+0x27 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1494]\r\n22 023df680 002eec71 search!std::_Func_impl<<lambda_e1cced59481f0ecb647ba0cb19582a2c>,std::allocator<int>,void,std::shared_ptr<restbed::Session> >::_Do_call+0x2c [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 211]\r\n23 023df6a4 0031adc7 search!std::_Func_class<void,std::shared_ptr<restbed::Session> >::operator()+0x41 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 275]\r\n24 023df720 0031ac08 search!restbed::detail::rule_engine+0x157 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\rule_engine_impl.hpp @ 52]\r\n25 023df82c 0031430d search!restbed::detail::ServiceImpl::router+0x278 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\service_impl.cpp @ 462]\r\n26 (Inline) -------- search!std::_Invoker_pmf_pointer::_Call+0x28 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1373]\r\n27 (Inline) -------- search!std::invoke+0x28 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n28 (Inline) -------- search!std::_Invoke_ret+0x28 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1508]\r\n29 (Inline) -------- search!std::_Call_binder+0x28 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 793]\r\n2a (Inline) -------- search!std::_Binder<std::_Unforced,void (__thiscall restbed::detail::ServiceImpl::*)(std::shared_ptr<restbed::Session>)const ,restbed::detail::ServiceImpl const * const &,std::_Ph<1> const &>::operator()+0x28 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 849]\r\n2b (Inline) -------- search!std::_Invoker_functor::_Call+0x28 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1408]\r\n2c (Inline) -------- search!std::invoke+0x28 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n2d (Inline) -------- search!std::_Invoke_ret+0x28 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1494]\r\n2e 023df848 002eec71 search!std::_Func_impl<std::_Binder<std::_Unforced,void (__thiscall restbed::detail::ServiceImpl::*)(std::shared_ptr<restbed::Session>)const ,restbed::detail::ServiceImpl const * const &,std::_Ph<1> const &>,std::allocator<int>,void,std::shared_ptr<restbed::Session> >::_Do_call+0x2d [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 211]\r\n2f 023df86c 0030e6c1 search!std::_Func_class<void,std::shared_ptr<restbed::Session> >::operator()+0x41 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 275]\r\n30 023df8a0 00314aa0 search!restbed::SessionManager::save+0x91 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\session_manager.cpp @ 57]\r\n31 023df908 003192ca search!restbed::detail::ServiceImpl::authenticate+0xb0 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\service_impl.cpp @ 613]\r\n32 023dfa58 0030efbc search!restbed::detail::ServiceImpl::parse_request+0x3fa [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\service_impl.cpp @ 726]\r\n33 023dfa80 003142d9 search!std::_Invoker_pmf_pointer::_Call<void (__thiscall restbed::detail::ServiceImpl::*)(std::error_code const &,unsigned int,std::shared_ptr<restbed::Session>)const ,restbed::detail::ServiceImpl const * &,std::error_code const &,unsigned int,std::shared_ptr<restbed::Session> &>+0x6c [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1375]\r\n34 (Inline) -------- search!std::invoke+0x13 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n35 (Inline) -------- search!std::_Invoke_ret+0x13 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1508]\r\n36 (Inline) -------- search!std::_Call_binder+0x13 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 793]\r\n37 (Inline) -------- search!std::_Binder<std::_Unforced,void (__thiscall restbed::detail::ServiceImpl::*)(std::error_code const &,unsigned int,std::shared_ptr<restbed::Session>)const ,restbed::detail::ServiceImpl const * const &,std::_Ph<1> const &,std::_Ph<2> const &,std::shared_ptr<restbed::Session> const &>::operator()+0x16 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 849]\r\n38 (Inline) -------- search!std::_Invoker_functor::_Call+0x16 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1408]\r\n39 (Inline) -------- search!std::invoke+0x16 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n3a (Inline) -------- search!std::_Invoke_ret+0x16 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1494]\r\n3b 023dfa9c 00307dc7 search!std::_Func_impl<std::_Binder<std::_Unforced,void (__thiscall restbed::detail::ServiceImpl::*)(std::error_code const &,unsigned int,std::shared_ptr<restbed::Session>)const ,restbed::detail::ServiceImpl const * const &,std::_Ph<1> const &,std::_Ph<2> const &,std::shared_ptr<restbed::Session> const &>,std::allocator<int>,void,std::error_code const &,unsigned int>::_Do_call+0x19 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 209]\r\n3c (Inline) -------- search!std::_Func_class<void,std::error_code const &,unsigned int>::operator()+0x1d [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 275]\r\n3d 023dfab4 00308f29 search!<lambda_809e54f05cd994ee845e807af8db6deb>::operator()+0x77 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\socket_impl.cpp @ 344]\r\n3e 023dfb44 003046f4 search!asio::detail::read_until_delim_string_op<asio::basic_stream_socket<asio::ip::tcp,asio::stream_socket_service<asio::ip::tcp> >,asio::basic_streambuf_ref<std::allocator<char> >,<lambda_12d3f708b7d2e653569cc9ff413d8d57> >::operator()+0x239 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\impl\\read_until.hpp @ 789]\r\n3f (Inline) -------- search!asio::detail::binder2<asio::detail::read_until_delim_string_op<asio::basic_stream_socket<asio::ip::tcp,asio::stream_socket_service<asio::ip::tcp> >,asio::basic_streambuf_ref<std::allocator<char> >,<lambda_12d3f708b7d2e653569cc9ff413d8d57> >,std::error_code,unsigned int>::operator()+0x11 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\bind_handler.hpp @ 160]\r\n40 023dfb58 0030ac8c search!asio::asio_handler_invoke<asio::detail::binder2<asio::detail::read_until_delim_string_op<asio::basic_stream_socket<asio::ip::tcp,asio::stream_socket_service<asio::ip::tcp> >,asio::basic_streambuf_ref<std::allocator<char> >,<lambda_12d3f708b7d2e653569cc9ff413d8d57> >,std::error_code,unsigned int> >+0x14 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\handler_invoke_hook.hpp @ 69]\r\n41 (Inline) -------- search!asio_handler_invoke_helpers::invoke+0x11 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\handler_invoke_helpers.hpp @ 37]\r\n42 (Inline) -------- search!asio::detail::asio_handler_invoke+0x11 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\impl\\read_until.hpp @ 837]\r\n43 (Inline) -------- search!asio_handler_invoke_helpers::invoke+0x11 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\handler_invoke_helpers.hpp @ 37]\r\n44 (Inline) -------- search!asio::detail::handler_work<asio::detail::read_until_delim_string_op<asio::basic_stream_socket<asio::ip::tcp,asio::stream_socket_service<asio::ip::tcp> >,asio::basic_streambuf_ref<std::allocator<char> >,<lambda_12d3f708b7d2e653569cc9ff413d8d57> >,asio::system_executor>::complete+0x11 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\handler_work.hpp @ 81]\r\n45 023dfc0c 002f602d search!asio::detail::win_iocp_socket_recv_op<asio::mutable_buffers_1,asio::detail::read_until_delim_string_op<asio::basic_stream_socket<asio::ip::tcp,asio::stream_socket_service<asio::ip::tcp> >,asio::basic_streambuf_ref<std::allocator<char> >,<lambda_12d3f708b7d2e653569cc9ff413d8d57> > >::do_complete+0x10c [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\win_iocp_socket_recv_op.hpp @ 98]\r\n46 (Inline) -------- search!asio::detail::win_iocp_operation::complete+0x15 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\win_iocp_operation.hpp @ 46]\r\n47 023dfc6c 002f7380 search!asio::detail::win_iocp_io_context::do_one+0x1ed [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\impl\\win_iocp_io_context.ipp @ 403]\r\n48 023dfca8 002f5724 search!asio::detail::win_iocp_io_context::run+0xd0 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\impl\\win_iocp_io_context.ipp @ 161]\r\n49 (Inline) -------- search!asio::io_context::run+0x21 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\impl\\io_context.ipp @ 59]\r\n4a (Inline) -------- search!restbed::Service::start::__l23::<lambda_01547af9600099e1a4714209b172393e>::operator()+0x23 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\service.cpp @ 178]\r\n4b (Inline) -------- search!std::_Invoker_functor::_Call+0x23 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1408]\r\n4c (Inline) -------- search!std::invoke+0x23 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n4d (Inline) -------- search!std::_LaunchPad<std::unique_ptr<std::tuple<<lambda_01547af9600099e1a4714209b172393e> >,std::default_delete<std::tuple<<lambda_01547af9600099e1a4714209b172393e> > > > >::_Execute+0x23 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\thr\\xthread @ 238]\r\n4e 023dfcd8 002f5466 search!std::_LaunchPad<std::unique_ptr<std::tuple<<lambda_01547af9600099e1a4714209b172393e> >,std::default_delete<std::tuple<<lambda_01547af9600099e1a4714209b172393e> > > > >::_Run+0xa4 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\thr\\xthread @ 245]\r\n4f 023dfce0 002f529a search!std::_LaunchPad<std::unique_ptr<std::tuple<<lambda_01547af9600099e1a4714209b172393e> >,std::default_delete<std::tuple<<lambda_01547af9600099e1a4714209b172393e> > > > >::_Go+0x6 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\thr\\xthread @ 230]\r\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\\Windows\\SysWOW64\\ucrtbase.DLL - \r\n50 023dfce8 714962a4 search!std::_Pad::_Call_func+0xa [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\thr\\xthread @ 208]\r\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\\Windows\\SysWOW64\\KERNEL32.DLL - \r\nWARNING: Stack unwind information not available. Following frames may be wrong.\r\n51 023dfd24 752d7c04 ucrtbase!crt_at_quick_exit+0x104\r\n52 023dfd38 7766ab8f KERNEL32!BaseThreadInitThunk+0x24\r\n53 023dfd80 7766ab5a ntdll!RtlInitializeExceptionChain+0x8f\r\n54 023dfd90 00000000 ntdll!RtlInitializeExceptionChain+0x5a\r\n```\r\n\r\nWe crash in mutable_buffer's ctor (for some reason) even though my call to Session::yield was guarded by is_open().\r\n\r\nHere is another callstack, this time on a different thread:\r\n\r\n```\r\n0:002> kn99\r\n # ChildEBP RetAddr  \r\n00 (Inline) -------- search!std::_Ref_count_base::_Decref+0x5 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\memory @ 110]\r\n01 (Inline) -------- search!std::_Ptr_base<void>::_Decref+0x9 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\memory @ 338]\r\n02 (Inline) -------- search!std::shared_ptr<void>::{dtor}+0x9 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\memory @ 573]\r\n03 (Inline) -------- search!std::shared_ptr<void>::reset+0x1a [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\memory @ 600]\r\n04 0230f730 00309c83 search!asio::detail::win_iocp_socket_service_base::close+0xb5 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\impl\\win_iocp_socket_service_base.ipp @ 186]\r\n05 (Inline) -------- search!asio::stream_socket_service<asio::ip::tcp>::close+0x19 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\stream_socket_service.hpp @ 162]\r\n06 (Inline) -------- search!asio::basic_socket<asio::ip::tcp,asio::stream_socket_service<asio::ip::tcp> >::close+0x25 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\basic_socket.hpp @ 352]\r\n07 0230f75c 00309fda search!restbed::detail::SocketImpl::close+0x83 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\socket_impl.cpp @ 91]\r\n08 0230f778 003045e1 search!restbed::detail::SocketImpl::connection_timeout_handler+0x3a [c:\\projects\\restbed\\source\\corvusoft\\restbed\\detail\\socket_impl.cpp @ 444]\r\n09 (Inline) -------- search!std::_Invoker_pmf_pointer::_Call+0xb [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1373]\r\n0a (Inline) -------- search!std::invoke+0xb [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n0b (Inline) -------- search!std::_Invoke_ret+0xb [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1508]\r\n0c (Inline) -------- search!std::_Call_binder+0xb [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 793]\r\n0d (Inline) -------- search!std::_Binder<std::_Unforced,void (__thiscall restbed::detail::SocketImpl::*)(std::error_code const &),restbed::detail::SocketImpl * const,std::_Ph<1> const &>::operator()+0xb [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\functional @ 849]\r\n0e (Inline) -------- search!asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall restbed::detail::SocketImpl::*)(std::error_code const &),restbed::detail::SocketImpl * const,std::_Ph<1> const &>,std::error_code>::operator()+0xe [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\bind_handler.hpp @ 62]\r\n0f 0230f784 0030a1f1 search!asio::asio_handler_invoke<asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall restbed::detail::SocketImpl::*)(std::error_code const &),restbed::detail::SocketImpl * const,std::_Ph<1> const &>,std::error_code> >+0x11 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\handler_invoke_hook.hpp @ 69]\r\n10 (Inline) -------- search!asio_handler_invoke_helpers::invoke+0xe [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\handler_invoke_helpers.hpp @ 37]\r\n11 (Inline) -------- search!asio::detail::handler_work<std::_Binder<std::_Unforced,void (__thiscall restbed::detail::SocketImpl::*)(std::error_code const &),restbed::detail::SocketImpl * const,std::_Ph<1> const &>,asio::system_executor>::complete+0xe [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\handler_work.hpp @ 81]\r\n12 0230f7c8 002f602d search!asio::detail::wait_handler<std::_Binder<std::_Unforced,void (__thiscall restbed::detail::SocketImpl::*)(std::error_code const &),restbed::detail::SocketImpl * const,std::_Ph<1> const &> >::do_complete+0x81 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\wait_handler.hpp @ 71]\r\n13 (Inline) -------- search!asio::detail::win_iocp_operation::complete+0x15 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\win_iocp_operation.hpp @ 46]\r\n14 0230f828 002f7380 search!asio::detail::win_iocp_io_context::do_one+0x1ed [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\impl\\win_iocp_io_context.ipp @ 403]\r\n15 0230f864 002f5724 search!asio::detail::win_iocp_io_context::run+0xd0 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\detail\\impl\\win_iocp_io_context.ipp @ 161]\r\n16 (Inline) -------- search!asio::io_context::run+0x21 [c:\\projects\\restbed\\dependency\\asio\\asio\\include\\asio\\impl\\io_context.ipp @ 59]\r\n17 (Inline) -------- search!restbed::Service::start::__l23::<lambda_01547af9600099e1a4714209b172393e>::operator()+0x23 [c:\\projects\\restbed\\source\\corvusoft\\restbed\\service.cpp @ 178]\r\n18 (Inline) -------- search!std::_Invoker_functor::_Call+0x23 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1408]\r\n19 (Inline) -------- search!std::invoke+0x23 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\type_traits @ 1476]\r\n1a (Inline) -------- search!std::_LaunchPad<std::unique_ptr<std::tuple<<lambda_01547af9600099e1a4714209b172393e> >,std::default_delete<std::tuple<<lambda_01547af9600099e1a4714209b172393e> > > > >::_Execute+0x23 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\thr\\xthread @ 238]\r\n1b 0230f894 002f5466 search!std::_LaunchPad<std::unique_ptr<std::tuple<<lambda_01547af9600099e1a4714209b172393e> >,std::default_delete<std::tuple<<lambda_01547af9600099e1a4714209b172393e> > > > >::_Run+0xa4 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\thr\\xthread @ 245]\r\n1c 0230f89c 002f529a search!std::_LaunchPad<std::unique_ptr<std::tuple<<lambda_01547af9600099e1a4714209b172393e> >,std::default_delete<std::tuple<<lambda_01547af9600099e1a4714209b172393e> > > > >::_Go+0x6 [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\thr\\xthread @ 230]\r\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\\Windows\\SysWOW64\\ucrtbase.DLL - \r\n1d 0230f8a4 713b62a4 search!std::_Pad::_Call_func+0xa [c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\include\\thr\\xthread @ 208]\r\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\\Windows\\SysWOW64\\KERNEL32.DLL - \r\nWARNING: Stack unwind information not available. Following frames may be wrong.\r\n1e 0230f8e0 752d7c04 ucrtbase!crt_at_quick_exit+0x104\r\n1f 0230f8f4 7766ab8f KERNEL32!BaseThreadInitThunk+0x24\r\n20 0230f93c 7766ab5a ntdll!RtlInitializeExceptionChain+0x8f\r\n21 0230f94c 00000000 ntdll!RtlInitializeExceptionChain+0x5a\r\n```\r\n\r\nOn another server thread my search was still going on. But there is a timeout? And I believe the client has disconnected at this point as well. Not sure what's going on here, but again: crash\r\n\r\nNot sure where to go with this, any advice would be appreciated! Ideally restbed should never crash: I'd be perfectly happy if an exception was thrown in all these cases."},"comment":{"url":"https://api.github.com/repos/Corvusoft/restbed/issues/comments/226911769","html_url":"https://github.com/Corvusoft/restbed/issues/110#issuecomment-226911769","issue_url":"https://api.github.com/repos/Corvusoft/restbed/issues/110","id":226911769,"user":{"login":"terrymah","id":203638,"avatar_url":"https://avatars.githubusercontent.com/u/203638?v=3","gravatar_id":"","url":"https://api.github.com/users/terrymah","html_url":"https://github.com/terrymah","followers_url":"https://api.github.com/users/terrymah/followers","following_url":"https://api.github.com/users/terrymah/following{/other_user}","gists_url":"https://api.github.com/users/terrymah/gists{/gist_id}","starred_url":"https://api.github.com/users/terrymah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terrymah/subscriptions","organizations_url":"https://api.github.com/users/terrymah/orgs","repos_url":"https://api.github.com/users/terrymah/repos","events_url":"https://api.github.com/users/terrymah/events{/privacy}","received_events_url":"https://api.github.com/users/terrymah/received_events","type":"User","site_admin":false},"created_at":"2016-06-18T00:49:12Z","updated_at":"2016-06-18T00:49:12Z","body":"i was using threads (immediately kicked off servicing a search request to a background thread so the restbed thread could get back to handling queries), but I removed them first thing and got the same behavior.\r\n\r\nIt takes 30+ seconds sometimes to perform a search. During this time, the thread which initially handled the request is constantly searching. When I call yield (once per result), could those possibly be handled by another worker thread? Could that run afoul of any internal multithreaded issues, especially if random closing of sockets is involved?\r\n\r\nI wonder if it's something as basic as a race condition: if other worker threads can handle yield requests, what's to stop one of them crashing if the connection closes between when I yield a buffer and it gets handled?\r\n\r\nI'm sorry, but I can't replicate it at all locally: even when my full stack server and client. It's only in production I'm seeing it. I am nearly certain there is a bug in the cilent (front end) here as well causing the disconnections.\r\n\r\nAlso: shouldn't yield itself check if the session is open? Otherwise it seems to me you must call session::is_open before every single yield call, and even that might not do it if the connection closes/has memory freed on a background worker thread between the is_open call and yield call"}}
{"actor":{"display_login":"terrymah"}}