id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 7552,win_iocp_io_service hangs due to a race condition,danielg@…,chris_kohlhoff,"The fix to #6321 introduced a bug that can cause the io_service to hang. Example code (hangs eventually): {{{ int main() { for (;;) { boost::asio::io_service ios; ios.post([]{ std::cout << '.'; }); boost::thread_group threads; for (size_t i = 0; i < 2; ++i) threads.create_thread([&]{ ios.run(); }); threads.join_all(); } } }}} Suppose that one of the threads read the posted operation, completed it and got to the ''work_finished'' function where it decremented ''outstanding_work'' to 0 and entered the ''stop'' function. Now the second thread starts. In the ''run'' function it sees that ''outstanding_work'' is 0 so it sets ''stopped'' to 1 and returns. Back in the first thread ''PostQueuedCompletionStatus(iocp_.handle, 0, 0, 0)'' isn't called since ''stopped'' is already 1. ''do_one'' returns 1 and is called again. ''GetQueuedCompletionStatus'' returns WAIT_TIMEOUT because the operation queue is empty, which causes the loop to continue to the next iteration ad infinitum.",Bugs,closed,To Be Determined,asio,Boost 1.49.0,Regression,fixed,asio windows hang,