I'm trying to do serializations using Boost's serialization library, but they always fail with the same unhelpful runtime error. Say, for example, I have a simple struct:
struct test {
unsigned int value;
template<class Archive>
void serialize(Archive & ar, unsigned int const version)
{
ar & BOOST_SERIALIZATION_NVP(value);
}
};
This compiles fine. Then I'm doing a round trip of saving object of the test
type to archive and loading it back again.
BOOST_AUTO_TEST_CASE(test_serialization)
{
test a{42};
stringstream ss;
text_oarchive oa(ss);
oa << BOOST_SERIALIZATION_NVP(a);
}
// ... lots of other tests that pass fine
This also compiles fine. However, I get the following error when running the suite.
Entering test case "test_serialization"
unknown location(0): fatal error in "test_serialization": memory access violation at address: 0x00000038: no mapping at fault address
Test is aborted
All other tests except those involving serialization run as expected.
What could cause the problem?
My settings:
Ubuntu 14.04
boost 1.57 / boost 1.58
clang 3.4 / gcc 4.8.2
Building with -lboost_serialization -lboost_unit_test_framework
.
Since I had multiple boost installations, boost headers included were from version 1.57/1.58, while the libboost_serialization.so
library was from version 1.54.
I recompiled with -L/actual/latest/boost/lib/path -lboost_serialization -lboost_unit_test_framework
, and it worked.
User contributions licensed under CC BY-SA 3.0