Memory access violation when using Boost::Serialization


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.

    test a{42};

    stringstream ss;
    text_oarchive oa(ss);

// ... 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.

asked on Stack Overflow Apr 23, 2015 by Bogdan Kulynych • edited Apr 23, 2015 by Bogdan Kulynych

1 Answer


Since I had multiple boost installations, boost headers included were from version 1.57/1.58, while the library was from version 1.54.

I recompiled with -L/actual/latest/boost/lib/path -lboost_serialization -lboost_unit_test_framework, and it worked.

answered on Stack Overflow Apr 23, 2015 by Bogdan Kulynych

User contributions licensed under CC BY-SA 3.0