|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62000 - trunk/boost/serialization
From: dgregor_at_[hidden]
Date: 2010-05-15 14:01:46
Author: dgregor
Date: 2010-05-15 14:01:45 EDT (Sat, 15 May 2010)
New Revision: 62000
URL: http://svn.boost.org/trac/boost/changeset/62000
Log:
Use collection_size_type/version_type consistently in
Boost.Serialization. This addresses a serious bug in Boost.MPI (see
bug #4214) that causes memory corruption with the skeleton/content
mechanism.
Text files modified:
trunk/boost/serialization/collections_load_imp.hpp | 13 +++++++------
trunk/boost/serialization/collections_save_imp.hpp | 6 +++---
trunk/boost/serialization/hash_collections_load_imp.hpp | 7 ++++---
trunk/boost/serialization/hash_collections_save_imp.hpp | 11 +++++++----
trunk/boost/serialization/optional.hpp | 8 +++++---
trunk/boost/serialization/slist.hpp | 6 ++++--
6 files changed, 30 insertions(+), 21 deletions(-)
Modified: trunk/boost/serialization/collections_load_imp.hpp
==============================================================================
--- trunk/boost/serialization/collections_load_imp.hpp (original)
+++ trunk/boost/serialization/collections_load_imp.hpp 2010-05-15 14:01:45 EDT (Sat, 15 May 2010)
@@ -139,12 +139,13 @@
s.clear();
// retrieve number of elements
collection_size_type count;
- unsigned int item_version;
+ unsigned int item_version_val = 0;
ar >> BOOST_SERIALIZATION_NVP(count);
- if(3 < ar.get_library_version())
- ar >> BOOST_SERIALIZATION_NVP(item_version);
- else
- item_version = 0;
+ if(3 < ar.get_library_version()) {
+ boost::archive::version_type item_version(0);
+ ar >> BOOST_SERIALIZATION_NVP(item_version);
+ item_version_val = item_version.t;
+ }
R rx;
rx(s, count);
std::size_t c = count;
@@ -152,7 +153,7 @@
BOOST_DEDUCED_TYPENAME Container::iterator hint;
hint = s.begin();
while(c-- > 0){
- hint = ifunc(ar, s, item_version, hint);
+ hint = ifunc(ar, s, item_version_val, hint);
}
}
Modified: trunk/boost/serialization/collections_save_imp.hpp
==============================================================================
--- trunk/boost/serialization/collections_save_imp.hpp (original)
+++ trunk/boost/serialization/collections_save_imp.hpp 2010-05-15 14:01:45 EDT (Sat, 15 May 2010)
@@ -41,10 +41,10 @@
// make sure the target type is registered so we can retrieve
// the version when we load
if(3 < ar.get_library_version()){
- const unsigned int item_version = version<
+ const boost::archive::version_type item_version(version<
BOOST_DEDUCED_TYPENAME Container::value_type
- >::value;
- ar << BOOST_SERIALIZATION_NVP(item_version);
+ >::value);
+ ar << BOOST_SERIALIZATION_NVP(item_version);
}
BOOST_DEDUCED_TYPENAME Container::const_iterator it = s.begin();
collection_size_type c=count;
Modified: trunk/boost/serialization/hash_collections_load_imp.hpp
==============================================================================
--- trunk/boost/serialization/hash_collections_load_imp.hpp (original)
+++ trunk/boost/serialization/hash_collections_load_imp.hpp 2010-05-15 14:01:45 EDT (Sat, 15 May 2010)
@@ -21,6 +21,7 @@
#include <boost/config.hpp>
#include <boost/serialization/nvp.hpp>
//#include <boost/serialization/collections_load_imp.hpp>
+#include <boost/serialization/collection_size_type.hpp>
namespace boost{
namespace serialization {
@@ -34,9 +35,9 @@
{
s.clear();
// retrieve number of elements
- unsigned int count;
- unsigned int item_version(0);
- unsigned int bucket_count;;
+ collection_size_type count;
+ boost::archive::version_type item_version(0);
+ collection_size_type bucket_count;
ar >> BOOST_SERIALIZATION_NVP(count);
if(3 < ar.get_library_version()){
ar >> BOOST_SERIALIZATION_NVP(bucket_count);
Modified: trunk/boost/serialization/hash_collections_save_imp.hpp
==============================================================================
--- trunk/boost/serialization/hash_collections_save_imp.hpp (original)
+++ trunk/boost/serialization/hash_collections_save_imp.hpp 2010-05-15 14:01:45 EDT (Sat, 15 May 2010)
@@ -22,6 +22,7 @@
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/version.hpp>
+#include <boost/serialization/collection_size_type.hpp>
namespace boost{
namespace serialization {
@@ -35,18 +36,20 @@
inline void save_hash_collection(Archive & ar, const Container &s)
{
// record number of elements
- unsigned int count = s.size();
+ unsigned int c = s.size();
+ collection_size_type count(c);
ar << BOOST_SERIALIZATION_NVP(count);
// make sure the target type is registered so we can retrieve
// the version when we load
if(3 < ar.get_library_version()){
- const unsigned int bucket_count = s.bucket_count();
+ const collection_size_type bucket_count(s.bucket_count());
ar << BOOST_SERIALIZATION_NVP(bucket_count);
- const unsigned int item_version = version<BOOST_DEDUCED_TYPENAME Container::value_type>::value;
+ const boost::archive::version_type item_version(
+ version<BOOST_DEDUCED_TYPENAME Container::value_type>::value);
ar << BOOST_SERIALIZATION_NVP(item_version);
}
BOOST_DEDUCED_TYPENAME Container::const_iterator it = s.begin();
- while(count-- > 0){
+ while(c-- > 0){
// note borland emits a no-op without the explicit namespace
boost::serialization::save_construct_data_adl(
ar,
Modified: trunk/boost/serialization/optional.hpp
==============================================================================
--- trunk/boost/serialization/optional.hpp (original)
+++ trunk/boost/serialization/optional.hpp 2010-05-15 14:01:45 EDT (Sat, 15 May 2010)
@@ -38,8 +38,8 @@
ar << boost::serialization::make_nvp("initialized", tflag);
if (tflag){
if(3 < ar.get_library_version()){
- const int v = version<T>::value;
- ar << boost::serialization::make_nvp("item_version", v);
+ const boost::archive::version_type v(version<T>::value);
+ ar << boost::serialization::make_nvp("item_version", v);
}
ar << boost::serialization::make_nvp("value", *t);
}
@@ -56,7 +56,9 @@
if (tflag){
unsigned int v = 0;
if(3 < ar.get_library_version()){
- ar >> boost::serialization::make_nvp("item_version", v);
+ boost::archive::version_type vt(v);
+ ar >> boost::serialization::make_nvp("item_version", vt);
+ v = vt.t;
}
detail::stack_construct<Archive, T> aux(ar, v);
ar >> boost::serialization::make_nvp("value", aux.reference());
Modified: trunk/boost/serialization/slist.hpp
==============================================================================
--- trunk/boost/serialization/slist.hpp (original)
+++ trunk/boost/serialization/slist.hpp 2010-05-15 14:01:45 EDT (Sat, 15 May 2010)
@@ -60,9 +60,11 @@
ar >> BOOST_SERIALIZATION_NVP(count);
if(std::size_t(0) == count)
return;
- unsigned int v;
+ unsigned int v = 0;
if(3 < ar.get_library_version()){
- ar >> boost::serialization::make_nvp("item_version", v);
+ boost::archive::version_type item_version(0);
+ ar >> BOOST_SERIALIZATION_NVP(item_version);
+ v = item_version.t;
}
boost::serialization::detail::stack_construct<Archive, U> u(ar, v);
ar >> boost::serialization::make_nvp("item", u.reference());
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk