Boost C++ Libraries: Ticket #5640: serialization vector backward compatibility problem https://svn.boost.org/trac10/ticket/5640 <p> We've recently upgraded from 1.40.0 to 1.46.1 and uncovered the following problem with vector serialization. </p> <p> In 1.40.0, the code to load a vector is: </p> <pre class="wiki">#ifndef BOOST_SERIALIZATION_VECTOR_VERSION #define BOOST_SERIALIZATION_VECTOR_VERSION 4 #endif ... template&lt;class Archive, class U, class Allocator&gt; inline void load( Archive &amp; ar, std::vector&lt;U, Allocator&gt; &amp;t, const unsigned int /* file_version */, mpl::true_ ){ collection_size_type count(t.size()); ar &gt;&gt; BOOST_SERIALIZATION_NVP(count); t.resize(count); unsigned int item_version=0; if(BOOST_SERIALIZATION_VECTOR_VERSION &lt; ar.get_library_version()) ar &gt;&gt; BOOST_SERIALIZATION_NVP(item_version); if (!t.empty()) ar &gt;&gt; make_array(detail::get_data(t),t.size()); } </pre><p> In 1.46.1, the same method is </p> <pre class="wiki">#ifndef BOOST_SERIALIZATION_VECTOR_VERSIONED #define BOOST_SERIALIZATION_VECTOR_VERSIONED(V) (V==4 || V==5) #endif ... template&lt;class Archive, class U, class Allocator&gt; inline void load( Archive &amp; ar, std::vector&lt;U, Allocator&gt; &amp;t, const unsigned int /* file_version */, mpl::true_ ){ collection_size_type count(t.size()); ar &gt;&gt; BOOST_SERIALIZATION_NVP(count); t.resize(count); unsigned int item_version=0; if(BOOST_SERIALIZATION_VECTOR_VERSIONED(ar.get_library_version())) { ar &gt;&gt; BOOST_SERIALIZATION_NVP(item_version); } if (!t.empty()) ar &gt;&gt; make_array(detail::get_data(t),t.size()); } </pre><p> Look at the difference when reading in a vector from serialization library version 4. In 1.40.0, the logic assumes that versions greater than 4 should read in item_version. In 1.46.1, the logic assumes that versions equal to 4 or 5 should read in item_version. So, if restoring a file saved with version 4, 1.40.0 will not ready in item_version but 1.46.1 will. </p> <p> We are working around this issue with a trick similar to the header vector_135.hpp, but would like to see this fixed in an upcoming release. </p> <p> After some research, I found this change was made with changeset 55415 for ticket 2271. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5640 Trac 1.4.3 Robert Ramey Sat, 25 Jun 2011 00:05:00 GMT owner changed https://svn.boost.org/trac10/ticket/5640#comment:1 https://svn.boost.org/trac10/ticket/5640#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Robert Ramey</span> to <span class="trac-author">Matthias Troyer</span> </li> </ul> <p> mattias - maybe you want to take a look at this </p> <p> Robert </p> Ticket Matthias Troyer Tue, 03 Jan 2012 18:01:01 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5640#comment:2 https://svn.boost.org/trac10/ticket/5640#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/76292" title="Attempting to fix #5640">[76292]</a>) Attempting to fix <a class="new ticket" href="https://svn.boost.org/trac10/ticket/5640" title="#5640: Bugs: serialization vector backward compatibility problem (new)">#5640</a> </p> Ticket Matthias Troyer Tue, 03 Jan 2012 18:02:26 GMT <link>https://svn.boost.org/trac10/ticket/5640#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5640#comment:3</guid> <description> <p> jfaust, can you try whether the trunk after <a class="changeset" href="https://svn.boost.org/trac10/changeset/76292" title="Attempting to fix #5640">[76292]</a> works for you? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 07 Feb 2012 17:35:39 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/5640#comment:4 https://svn.boost.org/trac10/ticket/5640#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> I don't think this has anything to do with MPI. I also don't think it's been solved. I'll take over here. If I can figure out how to reassign this ticket to me </p> <p> Robert Ramey </p> Ticket Robert Ramey Tue, 07 Feb 2012 17:38:25 GMT owner, status changed https://svn.boost.org/trac10/ticket/5640#comment:5 https://svn.boost.org/trac10/ticket/5640#comment:5 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Matthias Troyer</span> to <span class="trac-author">Robert Ramey</span> </li> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> </ul> Ticket