Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9612: Memory Access Violation when recursively serializing classes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-31 18:36:48
#9612: Memory Access Violation when recursively serializing classes
------------------------------------------+---------------------------
Reporter: Chris Rusby <chris.rusby@â¦> | Owner: ramey
Type: Bugs | Status: closed
Milestone: To Be Determined | Component: serialization
Version: Boost 1.55.0 | Severity: Problem
Resolution: invalid | Keywords:
------------------------------------------+---------------------------
Changes (by ramey):
* status: new => closed
* resolution: => invalid
Comment:
I've seen problems occur with DLLS when the "same" code is included in two
different DLLS.
This can occur when an inline serialization function is in a header which
is used by several DLLS. Each inline code generation ripples back to
include stuff in the library which ends up being duplicated. example
Instead of
{{{
// X.hpp
struct X {
template<class Archive>
serialize(Archive & ar, unsigned int file_version){
ar & ...
};
}}}
Use
{{{
// X.hpp
struct X {
template<class Archive>
serialize(Archive & ar, unsigned int file_version);
};
// X.cpp
// use explicit instantiation
template X::serialization<boost::serialization::text_iarchive>(
boost::serialization::text_iarchive & ar, unsigned int file_version){
ar >> ..
}
template X::serialization<boost::serialization::text_iarchive>(
boost::serialization::text_oarchive & ar, unsigned int file_version){
ar << ..
}
}}}
This will leave all the serialization code for X in one and only one
place. Thereby diminishing DLL hell and making DLLS smaller.
If someone want's to write an article on tis subject - organizing code in
DLLS, plugins using polymorphic versions of archives, etc.
I'll consider including it in the documentation.
Robert Ramey
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9612#comment:4> 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