Boost Users :
Subject: Re: [Boost-users] boost::bind - What if bound (method, instance) doesn't exist anymore?
From: Igor R (boost.lists_at_[hidden])
Date: 2011-10-06 11:56:18
> 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<B, A>(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
> What will be the result?
Crash (access violation / segfault).
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