sashafrey / topicmod

This project had been moved to https://github.com/bigartm/bigartm
Other
0 stars 0 forks source link

rpcz::connection_manager doesn't release sockets allocated in the MAIN thread #54

Closed sashafrey closed 9 years ago

sashafrey commented 10 years ago

I found a tricky problem in rpcz library. Notice that rpcz::connection_manager uses the boost::thread_Specific_ptr to allocate and deallocate ZeroMQ sockets. This is dangerous, because when new socket is allocated on MAIN thread it won't be deleted before PRCZ attempts to release the zmq::context_t. Releasing context hangs if any of sockets hasn't been closed.

class connection_manager { boost::thread_specific_ptrzmq::sockett socket; <-- thread-specific storage. };

sashafrey commented 10 years ago

To provoke this it is enough to call any rpcz-stub service from MAIN thread.

Example of the callstack when socket leaked: artm_tests.exe!rpcz::connection_manager::get_frontend_socket artm_tests.exe!rpcz::connection::send_request artm_tests.exe!rpcz::rpc_channel_impl::call_method_full artm_tests.exe!rpcz::rpc_channel_impl::call_method artm_tests.exe!artm::core::NodeControllerService_Stub::CreateOrReconfigureDataLoader artm_tests.exe!::operator() artm_tests.exe!std::_Callable_obj<,0>::_ApplyX<void,artm::core::NodeControllerService_Stub &> artm_tests.exe!std::_Func_implstd::_Callable_obj<<lambda_fb14e41c2c43c258d62f1cd70a17e93e,0>,std::allocator<std::_Func_class<void,artm::core::NodeControllerService_Stub &,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil> >,void,artm::core::NodeControllerService_Stub &,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::_Do_call artm_tests.exe!std::_Func_class<void,artm::core::NodeControllerService_Stub &,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::operator() artm_tests.exe!artm::core::NetworkClientCollection::for_each_client artm_tests.exe!artm::core::NetworkClientCollection::Reconfigure artm_tests.exe!artm::core::MasterComponent::Reconfigure

For now workaround is not to close zmq_context (see file \src\artm\zmq_context.h)

sashafrey commented 9 years ago

Issue is not fixed. Open a new ticket https://github.com/bigartm/bigartm/issues/85 to track this issue.