Boost.Asio's service_registry::do_use_service may block forever if a service with the same key was created
Hello boost developers, I found a bug in Boost.Asio on Windows using IOCP that can make the service_registry::do_use_service block forever if a service with the same key was created and registered while the mutex was unlocked. If the service uses win_iocp_io_context, its destructor (implicitly called upon return, by destroying new_service) will join() the internal thread for IOCP handling, without requesting it to stop before. This will leave both threads to block forever, while the mutex_ is still locked (lock's destructor may be called after new_services), which may cause further blockages in other threads. I submitted a PR ( https://github.com/boostorg/asio/pull/350 ) which aims to fix this by calling shutdown() on the thread before returning, and unlocking the mutex explicitly before that. Another solution would be to call shutdown() from within win_iocp_io_context::~win_iocp_io_context(). Regards, Niklas Gürtler
participants (1)
-
Niklas Gürtler