Boost logo

Boost Users :

From: gast128 (gast128_at_[hidden])
Date: 2007-03-05 04:37:14


Robert Ramey <ramey <at> rrsd.com> writes:

> To my mind, the best solution is to use smart_pointers
> and serialize them.

Hello Robert,

this gives me another problem (crash) when using an object consisting of two
shared pointers:

struct Bla
{
    template <class Archive>
    void serialize(Archive& ar, const unsigned int /*version*/)
    {
       ar & BOOST_SERIALIZATION_NVP(m_ptr);
       ar & BOOST_SERIALIZATION_NVP(m_ptr1);
    }

    boost::shared_ptr<int> m_ptr;
    boost::shared_ptr<int> m_ptr1;
};

If I try to load this, and let if fail while loading the second shared pointer
(because the file is corrupt) it crashes when using
the 'delete_created_pointers' option in the catch handler due to the fact that
the shared pointer wants to cleanup an already deleted pointer. Leaving this
option out does not crash it anymore, but results in some memory leaks.

But maybe I am taking now the serialziation library beyond its design limits.
These are all of course exceptional case.

wkr,
me


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