[Asio] Crash on service delete
Hi. I'm experiencing a crash when io_service destructor is called. The service was run on a separate thread and a socket was associated with it. The destruction sequence (on main thread, where the service was constructed) was as follows: // m_socket was associated with m_service m_socket->cancel(); m_socket->shutdown( boost::asio::ip::tcp::socket::shutdown_both, ec ); m_socket->close( ec ); delete m_socket; m_socket = NULL; // Delete work on the service delete m_work; m_work = NULL; // Stop the service m_service->stop(); // Join the thread this service was running on m_thread->interrupt(); m_thread->join(); delete m_thread; m_thread = NULL; // Crashes here delete m_service; m_service = NULL; Here's what VC10 reported: Access violation camc.exe!boost::asio::detail::socket_ops::send(unsigned int s, const _WSABUF * bufs, unsigned int count, int flags, boost::system::error_code & ec) Line 876 + 0x24 bytes C++ camc.exe!boost::asio::detail::socket_select_interrupter::interrupt() Line 127 + 0x18 bytes C++ camc.exe!boost::asio::detail::select_reactor::shutdown_service() Line 73 C++ camc.exe!boost::asio::detail::service_registry::~service_registry() Line 42 + 0xf bytes C++ camc.exe!boost::asio::detail::service_registry::`scalar deleting destructor'() + 0x16 bytes C++ camc.exe!boost::asio::io_service::~io_service() Line 51 + 0x1f bytes C++ camc.exe!boost::asio::io_service::`scalar deleting destructor'() + 0x16 bytes C++ Code crashes on Windows 7 (64bit, boost 1.46.1) and works on Ubuntu 11.04 (64bit, boost 1.42.0). Any ideas on what I'm missing? Thanks
participants (1)
-
Indrek Sünter