chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.85k stars 1.2k forks source link

win32: An invalid handle was specified. #1251

Closed matbech closed 1 year ago

matbech commented 1 year ago

During shutdown ::CloseHandle(exitevent); is called twice, which results in this exception: Exception thrown at 0x00007FFDF4F92D6A (ntdll.dll) in SmartFTP.exe: 0xC0000008: An invalid handle was specified.

It happens when asio::detail::win_iocp_io_context::shutdown() is called multiple times. The problem seems to be that the timer_thread is not reset here:

  if (timer_thread_.get())
    timer_thread_->join();
matbech commented 1 year ago

Landed in master: https://github.com/chriskohlhoff/asio/pull/1252