Boost.Asio's service_registry::do_use_service may block forever if a service with the same key was created

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Boost.Asio's service_registry::do_use_service may block forever if a service with the same key was created

Boost - Dev mailing list
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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost