Make sure that the object is alive as long as there are handlers that can use it.
Probably one of the handlers that uses this socket is called after you call close (since it reports an error to the handler), and then refers to the dead pointer ...
Typically, lifetime processing can be easily done with boost::shared_ptr and boost::enable_shared_from_this and passed in handlers. See Numerous examples with Boost.Asio.
Once you become familiar with this technique, the question you ask will look trivial for you.
source share