RE: [boost] Re: "memory access violation" in boost::serialization

Thanks Jeff, Your solution works - with a little twist: I took the solution from #20 (thanks Robert!) and now it loooks like: if(NULL != t.pi_) t.pi_->add_ref_copy(); I also outcommented line 125. & now my app works fine! We will, however, upgrade to #20 as soon as possible. Regarding the little discussion: it might very well be the case that uses find the library very usefull, without too many a problem. We certainly do, for instance on windows 2k (vc71) and HP True64 (probably gcc but I'm not sure). We have a lot of platforms here (HP, AIX, SUN, VMS, AS400 and Mainframe - with different versions of native compilers and/or gcc) and it is likely we will port to those platforms. If there's an interest, it might be possible to gather some figures. Cheers, Dirk -----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Jeff Flinn Sent: maandag 12 juli 2004 17:07 To: boost@lists.boost.org Subject: [boost] Re: "memory access violation" in boost::serialization "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 _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (1)
-
Dirk Griffioen