
6 Oct
2011
6 Oct
'11
3:56 p.m.
What happens when a boost::function is called and has been created with a (method, instance) combination, but the instance no longer exists?
What happens when this is in combination with boost::asio::io_service?
Here is my suspect code:
B::SharedPtr me = boost::dynamic_pointer_cast(shared_from_this()); callback = boost::bind(&B::Foo, me, boost::asio::placeholder::error);
// this is a boost::asio::ip::tcp::acceptor acceptor.async_accept(socket_, callback);
Now suppose I use a raw pointer instead. Now suppose the instance that just got bound was destroyed before the accept happened.
What will be the result?
Crash (access violation / segfault).