Subject: [Boost-bugs] [Boost C++ Libraries] #10086: Backwards compatibility to 1.42 adjacency list serialisation is broken
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-06-02 13:55:55
#10086: Backwards compatibility to 1.42 adjacency list serialisation is broken
------------------------------+------------------------
Reporter: oluedecke@⦠| Owner: jewillco
Type: Bugs | Status: new
Milestone: To Be Determined | Component: graph
Version: Boost 1.55.0 | Severity: Regression
Keywords: |
------------------------------+------------------------
I have an archive created with boost serialization of an adjacency list
which was created with boost 1.42.
When switching to Boost 1.55, the adjacency list cannot be deserialised
from the archive anymore.
I identified commit [77549] which probably broke the serialisation:
It appears that the vertex and edges are not wrapped in a 'property'
anymore, but stored directly in the adjacency list.
Additionaly, in [77615] a new member "graph_property" was added to the
serialisation code.
Unfortunately, the serialisation version number of adjacency list was not
incremented and the code in 'boost/graph/adj_list_serialize.hpp' was not
changed accordingly.
Furthermore in 'boost/pending/property_serialize.hpp', the serialisation
order of 'value' and 'base' was switched, again without changing the class
serialisation version number.
I was able to load the old archive by making following changes:
** adj_list_serialize.hpp **
{{{
template<class Archive, class OEL, class VL, class D,
class VP, class EP, class GP, class EL>
inline void load(
Archive & ar,
boost::adjacency_list<OEL,VL,D,VP,EP,GP,EL> &graph,
const unsigned int /* file_version */
){
typedef adjacency_list<OEL,VL,D,VP,EP,GP,EL> Graph;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::edge_descriptor Edge;
unsigned int V;
ar >> BOOST_SERIALIZATION_NVP(V);
unsigned int E;
ar >> BOOST_SERIALIZATION_NVP(E);
std::vector<Vertex> verts(V);
int i = 0;
while(V-- > 0){
// >>>>> BOOST_ADJ_LIST_1_42_SERIALIZATION_PATCH
if( ar.get_library_version() <= 7 /* not sure about the 7, could be a
greater version */){
Vertex v = add_vertex(graph);
boost::property<boost::vertex_bundle_t, VP> vertexAsProperty;
ar >> vertexAsProperty;
graph[v] = vertexAsProperty.m_value;
verts[i++] = v;
}
else
// <<<<< BOOST_ADJ_LIST_1_42_SERIALIZATION_PATCH
{
Vertex v = add_vertex(graph);
verts[i++] = v;
ar >> serialization::make_nvp("vertex_property", get(vertex_all_t(),
graph, v) );
}
}
while(E-- > 0){
// >>>>> BOOST_ADJ_LIST_1_42_SERIALIZATION_PATCH
if( ar.get_library_version() <= 7 /* not sure about the 7, could be a
greater version */){
int u; int v;
ar >> BOOST_SERIALIZATION_NVP(u);
ar >> BOOST_SERIALIZATION_NVP(v);
Edge e; bool inserted;
boost::tie(e,inserted) = add_edge(verts[u], verts[v], graph);
boost::property<boost::edge_bundle_t, EP> edgeAsProperty;
ar >> edgeAsProperty;
graph[e] = edgeAsProperty.m_value;
}
else
// <<<<< BOOST_ADJ_LIST_1_42_SERIALIZATION_PATCH
{
int u; int v;
ar >> BOOST_SERIALIZATION_NVP(u);
ar >> BOOST_SERIALIZATION_NVP(v);
Edge e; bool inserted;
boost::tie(e,inserted) = add_edge(verts[u], verts[v], graph);
ar >> serialization::make_nvp("edge_property", get(edge_all_t(),
graph, e) );
}
}
// >>>>> BOOST_ADJ_LIST_1_42_SERIALIZATION_PATCH
if(are_Adjacency_list_and_boost_property_in_old_format(ar) == false)
ar >> serialization::make_nvp("graph_property", get_property(graph,
graph_all_t()) );
// <<<<< BOOST_ADJ_LIST_1_42_SERIALIZATION_PATCH
}
}}}
** property_serialize.hpp **
{{{
template<class Archive, class Tag, class T, class Base>
void
serialize(Archive& ar, property<Tag, T, Base>& prop,
const unsigned int /*version*/)
{
// >>>>> BOOST_ADJ_LIST_1_42_SERIALIZATION_PATCH
if( ar.get_library_version() <= 7 /* not sure about the 7, could be a
greater version */){
ar & serialization::make_nvp( "property_base" , prop.m_base);
ar & serialization::make_nvp( "property_value" , prop.m_value );
}
else
// <<<<< BOOST_ADJ_LIST_1_42_SERIALIZATION_PATCH
{
ar & serialization::make_nvp( "property_value" , prop.m_value );
ar & serialization::make_nvp( "property_base" , prop.m_base );
}
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10086> 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:16 UTC