Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7185801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:29:44+00:00 2026-05-28T18:29:44+00:00

I have a made a simple program that reproduces the problem: #include <boost/archive/text_oarchive.hpp> #include

  • 0

I have a made a simple program that reproduces the problem:

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/tuple/tuple.hpp>
#include <sstream>
#include <iostream>    

template<typename T>
std::string serialize(const T & value)
{
    std::ostringstream oss;
    boost::archive::text_oarchive oa(oss);
    oa << value;
    return oss.str();
}    

template<typename T>
T deserialize(const std::string & buffer)
{
    std::istringstream iss(buffer);
    boost::archive::text_iarchive ia(iss);
    T ret;
    ia >> ret;
    return ret;
}    

struct MyClass
{
    MyClass() {}
    MyClass(const std::string & name) : name(name) {}

    template<class Archive>
    void serialize(Archive & ar, const unsigned int)
    {
        ar & name;
    }

    std::string name;
};    

int main()
{
    MyClass myClass("Test");
    std::string serialized = serialize(myClass);
    std::cout << "Serialized: " << serialized << std::endl;
    MyClass deserialized = deserialize<MyClass>(serialized);
    std::cout << "Name after deserialization: " << deserialized.name << std::endl;
}

The code compiles fine, but gives the following error at runtime:

Serialized: 22 serialization::archive 9 0 0 4 Test
test(74010) malloc: *** error for object 0x109bf55e0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

In the debugger I can see that the error occurs when boost tries to deserialize the name variable.

Can anyone help me figure out what I’m doing wrong?

Update

I’m on Mac OS X Lion and using GCC 4.6.2 (g++-mp-4.6 (GCC) 4.6.2) and boost version 1.48. Both installed via MacPorts.

Command line is:

g++ -o test -I/opt/local/include -L/opt/local/lib main.cpp -lboost_serialization

You can checkout the code from subversion here: http://stacked-crooked.googlecode.com/svn/trunk/Playground/Serialization .

Update

I tested on Linux GCC 4.6.1 and boost 1.48 and it works fine. It somehow must be an issue specific to my configuration on Mac.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:29:45+00:00Added an answer on May 28, 2026 at 6:29 pm

    What happened was this:

    1. Boost was built by MacPorts using the built-in Apple GCC 4.2.
    2. I was compiling my program with non-Apple GCC 4.6.2 (also obtained from MacPorts).
    3. The boost binary that was loaded at runtime was not compatible with my binary.
    4. Crash!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning java and I have made simple program that simply reads value from
Hi i have made a simple program that plays a video file, i used
I have made my own file type (.ddd) and I made a simple program
I have started using jQuery and rails. I have made a simple form that
I have made a very simple AppleScript to close tabs in Safari. The problem
I have a simple software that is made in Delphi 7, and it crashes
I have made a program in Flex for creating simple schedules, similar to MS
I made a simple java program that sends bytes to the parallel port, which
I have made a program that list all files and folders(f&f) locating on sd
I have a program i frequently use that is made with .NET. This program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.