Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9601: Unable to load archives with pointer instances which contain self reference cycles in 1.55
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-22 20:12:14
#9601: Unable to load archives with pointer instances which contain self reference
cycles in 1.55
-------------------------------+---------------------------
Reporter: brandon.kohn | Owner: ramey
Type: Bugs | Status: assigned
Milestone: To Be Determined | Component: serialization
Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+---------------------------
Comment (by brandon.kohn):
Replying to [comment:1 ramey]:
> boy - I bet this cost a lot of effort to figure out.
Yeah, it's fun stuff :). Anyone who doesn't appreciate the intricacies of
implementing a serialization library needs to spend time debugging one.
>
> Note that the test set includes a specific test for cyclic pointers
which is passing.
>
> I'm thinking that the difference between that test and your test isn't
so much a cycle as a self referential object.
If you mean serialization\test\test_cyclic_ptrs.cpp, I'll give it a more
thorough look.
We've been using boost serialization at my work for our application files
and have just recently moved from 1.53 to 1.55 to support vc12. The use
case where I found this was more complex than the unit-test as it involved
polymorphic types held in shared_ptr instances with the cyclic reference
being held inside a std::map member variable. The unit-test was just the
most simple cycle I could think of which illustrated the issue.
> I'm also thinking that the correct fix is to tweak the code so that it
addresses the special case of a self referential object such as yours.
> *snip*
> This is predicated on my guess that this is really just a corner case I
failed to consider and not some fundamental issue which requires a major
overhaul. If I'm wrong about this, feel free to let me know.
>
My suspicion is that it would affect any cycle, but I've been wrong before
;). I'm already having a think about how I would fix it.
One note is that it worked in 1.53. It seems to have stopped working when
a change was made to :
{{{
#!c++
// remember that that the address of these elements could change
// when we make another call so don't use the address
bpis_ptr->load_object_ptr(
ar,
t,//! used to be object_id_vector[ui].address
m_pending.version
);
}}}
And then in iserializer.hpp (the old version before SHA:
8af0e20bb091631a153147587d7958492be623ae):
{{{
#!c++
BOOST_DLLEXPORT void pointer_iserializer<Archive, T>::load_object_ptr(
basic_iarchive & ar,
void * & x,
const unsigned int file_version
) const
{
Archive & ar_impl =
boost::serialization::smart_cast_reference<Archive &>(ar);
auto_ptr_with_deleter< T > ap(heap_allocator< T >::invoke());
if(NULL == ap.get())
boost::serialization::throw_exception(std::bad_alloc()) ;
T * t = ap.get();
x = t;//! This would update the object_id_vector[ui].address member
with the right ptr.
}}}
The new code doesn't do this. So my first idea for a fix would be to
create a version of load_object_ptr with an overload to update the address
member of that vector as before.
There is a comment:
{{{
#!c++
// remember that that the address of these elements could change
// when we make another call so don't use the address
}}}
It makes me wonder if there's something funky that can happen to that
address which I might be missing.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9601#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC