Boost logo

Boost Users :

From: Ross Manges (ross.manges_at_[hidden])
Date: 2005-05-05 13:05:14


> Your problem is not related to shared_from_this at all:
>
> void SimpleQueue1::add(ElementPtr elem)
> {
> queue.push_back(elem);
> }
>
> You just forgot to protect queue.push_back by locking the queue mutex.

Just posting a last follow up. We've finally got our coding working well,
and as it turns out, none of our shared_ptr problems were not actually
shared_ptr problems, as you might have guessed. Most of our problems came
from vectors or maps that were not locked down appropriately with muticies
(like the example above). One serious bug that had us stumped for a long
time was the rules for the validity of an iterator to a stl vector. We
were calling my_vector.erase(it) and then happily using 'it' in a loop,
not realizing that 'it' had been invalidated by the erase. Just a simple
oversight that cost us a lot of hair-pulling and teeth grinding. It made
the debugging even more difficult because all of our backtraces pointed to
the shared_ptr scope_lock, which kept diverting us from the real cause.
Anyway, thanks for all of your help. The Boost community has been great!

--Ross


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