|
Boost Users : |
Subject: Re: [Boost-users] [Asio] Crash on service delete
From: Marat Abrarov (abrarov_at_[hidden])
Date: 2011-06-24 13:58:07
Hi, Indrek.
> // 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++
May be the source of your problem is located in yours async write completion handler (it is often so - see asio-users
mailing list). It seems that your completion handler tries to use destroyed m_socket.
Regards,
Marat Abrarov.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net