c++ - Boost serialization to XML crashes -
i'm experiencing wierd crash while trying serialize object using boost. interestingly problem occurs when compile project in release mode. in debug mode works fine , xml file written correctly.
here code class supposed serialized. member variable "weights" pointer array dynamically allocated during object construction.
[...] private: [...] int numorientations; int numscales; float thresh; float* weights; friend class boost::serialization::access; template<class archive> void serialize(archive& ar, const unsigned int version) { using boost::serialization::make_nvp; using boost::serialization::make_array; ar & make_nvp("numorient", numorientations); ar & make_nvp("numscales", numscales); ar & make_nvp("thresh", thresh); ar & make_nvp("weights", make_array(weights, numscales*4 + 1)); }
the whole thing called by:
std::fstream mpbcstr("test.xml", std::fstream::trunc | std::fstream::out); boost::archive::xml_oarchive xml(mpbcstr); <-- program executes fine until here xml << boost::serialization::make_nvp("gpbconfig", configg); <-- not reached mpbcstr.close();
since works fine in debug mode. tried pin down location of error printing debug statements after every line. marked lines in code above code crashes. funny thing in serialization function not first line executed before crash.
the error getting is:
first-chance exception @ 0x000000013f4c31cd in rungpb.exe: 0xc0000005: access violation reading location 0x000000003d4ccccd.
not helpful, know. suggestions problem appreciated.
i'm experiencing wierd crash while trying serialize object using boost. interestingly problem occurs when compile project in release mode. in debug mode works fine , xml file written correctly. here code class supposed serialized. member variable "weights" pointer array dynamically allocated during object construction. the whole thing called by: since works fine in debug mode. tried pin down location of error printing debug statements after every line. marked lines in code above code crashes. funny thing in serialization function not first line executed before crash. the error getting is: not helpful, know. suggestions problem appreciated. | ||||
weights
numscales*4+1
elements long ?make_array(weights, numscales*4 + 1)
.... , pointer initialized ? – matthieu m. jul 7 '12 @ 13:46