Hello,

 

I'm using boost::asio on WinXP64, with boost 1.39. My app is deadlocking during destruction of a static object that has an io_service member variable.

 

If I explicitly delete the static object, no deadlock occurs. The static object is actually a shared_pointer, which points to the object I mentioned above. So at exit, assuming I haven't explicitly deleted the object, once the reference count reaches zero, delete is called, and the process deadlocks.

 

The offending piece of code appears to be in win_thread.hpp:143.

  void join()

  {

    ::WaitForSingleObject(exit_event_, INFINITE);

    ::CloseHandle(exit_event_);

    if (terminate_threads())

    {

      ::TerminateThread(thread_, 0);

    }

    else

    {

      ::QueueUserAPC(apc_function, thread_, 0);

      ::WaitForSingleObject(thread_, INFINITE);

    }

  }

 

It is blocked at ::WaitForSingleObject(exit_event_, INFINITE);

 

(This is as a result of the destruction of the io_service member).

 

In case it's significant, the io_service object is used to establish several socket connections (to and from remote hosts), some of which are through socket.connect, and others through socket.connect_async.

 

Thanks!

Danny