Boost 1_41 Binary archive exceptions

I am porting from Linux 32 bit to 64 Bit(x86_64)(Boost Version :1_41). I am facing an Binary archive exceptions mainly (std::bad_alloc,St12length_error-basic_string::resize). There are no exception during the file saving, but when I do a restore I am facing the above exceptions. The same works very well if I change it to text archives. How can I make it work with binary files? The exception is happening in the below code block .Any comments please template<class Archive> void Serialise (Archive & aArchive, const unsigned int aVersion=0) { aArchive & this->A; aArchive & this->B; aArchive & this->C this->p.Serialise(aArchive, aVersion); } -- View this message in context: http://boost.2283326.n4.nabble.com/Boost-1-41-Binary-archive-exceptions-tp42... Sent from the Boost - Dev mailing list archive at Nabble.com.

Is any of your fields (A, B, C) have type [unsigned] long or size_t ? These types are 32-bit in 32-bit gcc and 64-bit in 64-bit one, so it reads completely different values If you are reading with 64-bit application files that are created in 32-bit one then that's the problem. 2011/12/29 KARAN <msree80@yahoo.co.in>
I am porting from Linux 32 bit to 64 Bit(x86_64)(Boost Version :1_41). I am facing an Binary archive exceptions mainly (std::bad_alloc,St12length_error-basic_string::resize).
There are no exception during the file saving, but when I do a restore I am facing the above exceptions. The same works very well if I change it to text archives. How can I make it work with binary files?
The exception is happening in the below code block .Any comments please template<class Archive> void Serialise (Archive & aArchive, const unsigned int aVersion=0) {
aArchive & this->A; aArchive & this->B; aArchive & this->C this->p.Serialise(aArchive, aVersion);
}
-- View this message in context: http://boost.2283326.n4.nabble.com/Boost-1-41-Binary-archive-exceptions-tp42... Sent from the Boost - Dev mailing list archive at Nabble.com.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Hi The A,B, C of types below T A; T B; CLASS::CLASSB C; I am saving the files in 64bit env successfully and restore the same file which leads to exception mainly in this below block { T A; T B; CLASS::CLASSB C; } Regards SKaran -- View this message in context: http://boost.2283326.n4.nabble.com/Boost-1-41-Binary-archive-exceptions-tp42... Sent from the Boost - Dev mailing list archive at Nabble.com.

Hi this is how it looks nel::OriginTaggedUsername mUsername; template<class Archive> void Serialise (Archive & aArchive, const unsigned int aVersion=0) { this->mUsername.Serialise(aArchive, aVersion); //when this call tooks place exception will happen in the below Serialise function of OriginTaggedData class aArchive & this->mSrcIP; aArchive & this->mSrcPort; } template< class T> class OriginTaggedData { public: template<class Archive> void Serialise (Archive & aArchive, const unsigned int aVersion=0) { aArchive & this->mValue; aArchive & this->mOrigin; } void Reset (void) { this->mValue = this->mUnknownValue; this->mOrigin = Secerno::SessionDataOriginNone; } const T& Value(void) const { return (this->mValue); } rno::SessionDataOrigin Origin(void) const { return (this->mOrigin);} std::string ToString (void) const { std::ostringstream lStrm; return (lStrm.str()); } private: T mUnknownValue; T mValue; rno::SessionDataOrigin mOrigin; protected: OriginTaggedData (const T& aUnknownValue) : mUnknownValue(aUnknownValue) { this->Reset(); } }; class OriginTaggedUsername : public OriginTaggedData<std::string> { public: OriginTaggedUsername (void) : OriginTaggedData<std::string>(rno::GetUnknownUsername()) { } ~OriginTaggedUsername (void) { } protected: private: }; -- View this message in context: http://boost.2283326.n4.nabble.com/Boost-1-41-Binary-archive-exceptions-tp42... Sent from the Boost - Dev mailing list archive at Nabble.com.

On Thu, Dec 29, 2011 at 10:43 AM, KARAN <msree80@yahoo.co.in> wrote:
I am porting from Linux 32 bit to 64 Bit(x86_64)(Boost Version :1_41). I am facing an Binary archive exceptions mainly (std::bad_alloc,St12length_error-basic_string::resize).
There are no exception during the file saving, but when I do a restore I am facing the above exceptions. The same works very well if I change it to text archives. How can I make it work with binary files?
Just a wild guess, did you open the file/stream as binary? What platform are you using? -- Olaf

Hi I have opened the files as below : Saving : std::ofstream OFile (aFilename.c_str(), std::ios::binary); Restore : std::ifstream IFile (aFilename.c_str(), std::ios::binary); Platform : Linux x86_64 -- View this message in context: http://boost.2283326.n4.nabble.com/Boost-1-41-Binary-archive-exceptions-tp42... Sent from the Boost - Dev mailing list archive at Nabble.com.

Here is my Stack Trace of exception:51 the T is an ENUM..lokks getting null? #0 boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char>
::load_override<boost::serialization::nvp<int> const> (this=0x7fffffffc2e0, t=...) at /usr/include/boost/archive/binary_iarchive_impl.hpp:45 #1 0x0000000000550992 in boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><boost::serialization::nvp<int> const> (this=0x7fffffffc2e0, t=...) at /usr/include/boost/archive/detail/interface_iarchive.hpp:61 #2 0x00000000005507f1 in boost::archive::detail::load_enum_type<boost::archive::binary_iarchive>::invoke<Secerno::SessionDataOrigin> (ar=..., t=@0x824b78) at /usr/include/boost/archive/detail/iserializer.hpp:500 #3 0x000000000055054d in boost::archive::load<boost::archive::binary_iarchive, Secerno::SessionDataOrigin> (ar=..., t=@0x824b78) at /usr/include/boost/archive/detail/iserializer.hpp:554 #4 0x00000000005501fe in boost::archive::detail::common_iarchive<boost::archive::binary_iarchive>::load_override<Secerno::SessionDataOrigin> (this=0x7fffffffc2e0, t=@0x824b78) at /usr/include/boost/archive/detail/common_iarchive.hpp:61 #5 0x000000000054fa89 in boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<Secerno::SessionDataOrigin> (this=0x7fffffffc2e0, t=@0x824b78, version=0) at /usr/include/boost/archive/basic_binary_iarchive.hpp:62 #6 0x000000000054ecb5 in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::load_override<Secerno::SessionDataOrigin> (this=0x7fffffffc2e0, t= @0x824b78) at /usr/include/boost/archive/binary_iarchive_impl.hpp:45 #7 0x000000000054d2f8 in boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><Secerno::SessionDataOrigin> (this=0x7fffffffc2e0, t=@0x824b78) at /usr/include/boost/archive/detail/interface_iarchive.hpp:61 #8 0x000000000054b83b in boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator&<Secerno::SessionDataOrigin> (this=0x7fffffffc2e0, t=@0x824b78) at /usr/include/boost/archive/detail/interface_iarchive.hpp:68 #9 0x0000000000549405 in Secerno::Kernel::OriginTaggedData<std::basic_string<char, std::char_traits<char>, std::allocator<char> > ::Serialise<boost::archive::binary_iarchive> (this=0x824b60, aArchive=..., aVersion=2) at ../src/KernelTypes/OriginTaggedData.h:129 #10 0x0000000000546f67 in Secerno::Kernel::SessionData::Serialise<boost::archive::binary_iarchive> (this=0x824b60, aArchive=..., aVersion=2) at ../src/KernelTypes/SessionData.h:173 #11 0x000000000053e73a in Secerno::Stitcher::Utils::SessionContext::Cache::RestoreSingleSessionData (this=0x7f44c0, aArch=..., apPDI=0x818fd0, aVersion=2, aDeleteExisting=false) at ../src/stitcher/Utils/SessionContextCache.cpp:1104 #12 0x000000000053e000 in Secerno::Stitcher::Utils::SessionContext::Cache::RestoreFromFile (this=0x7f44c0, aFilename=
"/tmp/CSessionContextPersistTests_19056_1325292676_727/SerialisedSessionContexts.txt", apPDI=0x818fd0, aDD=DbfwEngineDatabaseDialectSqlServer, aDeleteExisting=false) at ../src/stitcher/Utils/SessionContextCache.cpp:1035 #13 0x000000000051b58f in CSessionContextPersistTests::fullSerialiseAndRestore (this=0x815b10) at ../test/StitcherUtils//SessionContextPersistTests.cpp:761 #14 0x000000000052eb98 in CppUnit::TestCaller<CSessionContextPersistTests>::runTest (this=0x815c30) at /tmp/linux-x86_64/cppunit/include/cppunit/TestCaller.h:166 #15 0x00007ffff6766c4a in CppUnit::TestCaseMethodFunctor::operator() (this=<value optimized out>) at TestCase.cpp:32 #16 0x00007ffff675bfa4 in CppUnit::DefaultProtector::protect (this=0x80dd00, functor=<value optimized out>, context=...) at DefaultProtector.cpp:15 #17 0x00007ffff6763597 in CppUnit::ProtectorChain::protect (this=0x80da40, functor=..., context=...) at ProtectorChain.cpp:77 #18 0x00007ffff676c784 in CppUnit::TestResult::protect (this=0x80d740, functor=..., test=<value optimized out>, shortDescription=<value optimized out>) at TestResult.cpp:178 #19 0x00007ffff6766928 in CppUnit::TestCase::run (this=0x815c30, result=0x80d740) at TestCase.cpp:92 #20 0x00007ffff6766fd3 in CppUnit::TestComposite::doRunChildTests (this=0x8157e0, controller=0x80d740) at TestComposite.cpp:64 #21 0x00007ffff6766ef6 in CppUnit::TestComposite::run (this=0x8157e0, result=0x80d740) at TestComposite.cpp:23 #22 0x00007ffff6766fd3 in CppUnit::TestComposite::doRunChildTests (this=0x80fdb0, controller=0x80d740) at TestComposite.cpp:64 #23 0x00007ffff6766ef6 in CppUnit::TestComposite::run (this=0x80fdb0, result=0x80d740) at TestComposite.cpp:23 #24 0x00007ffff676c52a in CppUnit::TestResult::runTest (this=0x80d740, test=0x80d180) at TestResult.cpp:145 #25 0x00007ffff676e4a3 in CppUnit::TestRunner::run (this=<value optimized out>, controller=..., testPath=<value optimized out>) at TestRunner.cpp:96 #26 0x00007ffff677097b in CppUnit::TextTestRunner::run (this=0x7fffffffd550, testName="", doWait=false, doPrintResult=true, doPrintProgress=true) at TextTestRunner.cpp:64 #27 0x00000000004a93a3 in main (argc=1, argv=0x7fffffffd718) at ../test/StitcherUtils//StitcherUtilsTestsMain.cpp:66 -- View this message in context: http://boost.2283326.n4.nabble.com/Boost-1-41-Binary-archive-exceptions-tp42... Sent from the Boost - Dev mailing list archive at Nabble.com.
participants (3)
-
KARAN
-
Olaf van der Spek
-
Yuriy Zubritsky