I’ve seen this several times causing troubles:
boost::shared_ptr<Foo> p(new Foo); boost::thread t(boost::bind(&Foo::method, p.get()))
This prevents the livecycle management of
shared_ptr or any other smart pointer to be effective in the thread. Hence,
p may get destructed even though the thread is still active.
Boost bind can handle smart pointers, so instead use the smart pointer itself as the instance argument for bind:
boost::thread t(boost::bind(&Foo::method, p))