shared_ptr Assertion px != 0 failed

Viewed 51683

I have a fairly complex multi threaded application (server) that from time to time will crash due to an assert:

/usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr< <template-parameter-1-1> >::operator->() const [with T = msg::Player]: Assertion `px != 0' failed.

I have been unable to pinpoint the cause and was wondering if this is a problem with boost::shared_ptr or it is me?

I tried g++ 4.4.3-4ubuntu5 and llvm-g++ (GCC) 4.2.1 with optimization and without optimization and libboost1.40-dev (= 1.40.0-4ubuntu4).

3 Answers

Here's to reviving an ancient question. I just hit this, and it was due to a timing issue. I was trying to use the shared_ptr from one thread before I'd finished initializing it in another.

So if someone hits the above message, check your timing to ensure your shared_ptr has been initialized.

Related