@Peter:

You were right, one of the threads was explicitly deleting the list and hence the cause for the crash. Thanks for your help.

-Samm

On Thu, Jan 5, 2012 at 3:38 AM, Peter Dimov <pdimov@pdimov.com> wrote:
sumanth krishna wrote:
C is a singleton class and from the logs i can see that the other threads have exited before the destructor of C is called.

Well, in this case you should try to isolate a complete program that crashes and post it here.

Even if the thread calls c->getList after ~C is executed, then also it should not cause a problem because until all the instances are deleted and reference count of the shared pointers reaches zero the memory for the allocated class should not be deleted.

No, destroying a shared_ptr in one thread and copying it from another doesn't work. Even if it did, destroying a std::list in one thread and iterating over it from another doesn't work either. If you access an object from more than one thread, all accesses must be read (non-modifying) accesses.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users