boost:shared_ptr destructor, SIGBUS, MIPS 64

I am using a STL list of boost shared pointer in my code and and it
randomly dumps core. Below is the code snippet and the core stack.
class A ()
{
virtual ~A();
string getsomestring();
}
class B: public A
{
}
typedef shared_ptr<A> A_ptr;
class C // singelton class
{
public:
getList(list ::destroy (this=0xffffeaf640, __p=0x1200b08d0) #5 0x000000012003c9e0 in std::_List_base

sumanth krishna wrote:
#8 0x0000000120068b64 in C::~C (this=0x1200a8e70, __in_chrg=<value optimized out>)
Is it possible for a thread to still be calling c->getList when ~C is
executed?
Based on your (pseudo)code, a number of temporary std::list

Peter Dimov Wrote:
##################################################################
Is it possible for a thread to still be calling c->getList when ~C is
executed?
Based on your (pseudo)code, a number of temporary std::list
sumanth krishna wrote:
#8 0x0000000120068b64 in C::~C (this=0x1200a8e70, __in_chrg=
optimized out>)
Is it possible for a thread to still be calling c->getList when ~C is executed?
Based on your (pseudo)code, a number of temporary std::list
instances are created and destroyed without a problem before C's member, so list destruction on its own seems to work fine. ______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**users

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.

@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
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-**usershttp://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Peter Dimov
-
sumanth krishna