
"Dirk Griffioen" <d.griffioen@HumanInference.com> wrote in message news:2505062E579A9B45888B70D9BCFB3C073BA8BD@ex03.hidomain...
Hi,
I encountered the following little problem:
I would like to use the following datastructures with boost::serialize:
struct Match {}; typedef std::string Key; typedef tst< Match, Key > TernarySearchTree; //this one has a shared_ptr
typedef std::vector< TernarySearchTree > Trees; typedef std::map< std::string, Trees > Symbols;
I have defined some serialize overloads so saving goes fine, but when loading I get a "memory acces violation" inside the following code:
{ boost::archive::text_iarchive ia(ifs); ia >> symbols_; }
More specific, inside <boost/serializiton/shared_count.hpp>
void add_ref_copy() { #if defined(BOOST_HAS_THREADS) mutex_type::scoped_lock lock(mtx_); #endif ++use_count_; }
Which constructs a scoped_lock, and there, the "explicit scoped_lock(lightweight_mutex & m): m_(m)" seems to go wrong.
Actually you'll find that the this pointer is either NULL or invalid.
What could be the reason? The more since all worked fine (saving and loading) when I used a simple vector of tst's.
The following changes to .../boost/serialization/shared_ptr.hpp should do it: change line 74: if(t) t->add_ref_copy(); and comment out line 125: // shared_ptr_access::weak_count(*t) = 0; IIRC, line 125 is the primary culprit. ----------------- Jeff Flinn Applied Dynamics, International