Boost logo

Boost Users :

Subject: Re: [Boost-users] boost:shared_ptr destructor, SIGBUS, MIPS 64
From: Peter Dimov (pdimov_at_[hidden])
Date: 2012-01-04 17:08:55


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 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