[Serialization] Sometimes Fails Reading Binary File

Hi, I am using Boost 1.43.0, Linux 2.6.23, gcc version 4.0.0 on a Freescale PowerPC. I am reading in a serialized binary file using Ifstream ifs; try { Ifs.open(filename.c_str(), iso_base::binary | iso_base::in); If(fs.is_open()) { Boost::archive::binary_iarchive ia(ifs); ia >> data; ifs.close(); } } catch (std:exception &e) { Ifs.close(); } Sometimes it reads the file fine and sometimes it throws one of the following errors. invalid_signature, Basic_string::resize, or stream error. Does anyone have an idea why sometimes it works and sometimes it does not work? Best regards, Robert McCullough Senior Software Engineer Promess Incorporated 11429 Grand River Road Brighton, Michigan 48116 Email: mailto://rob@promessdev.com mailto://rob@promessinc.com Web: http://promessinc.com/ http://promessinc.com Tel: (810) 229-9334 Fax: (810) 229-8125

AMDG Robert McCullough wrote:
I am using Boost 1.43.0, Linux 2.6.23, gcc version 4.0.0 on a Freescale PowerPC.
I am reading in a serialized binary file using
Ifstream ifs; try { Ifs.open(filename.c_str(), iso_base::binary | iso_base::in); If(fs.is_open()) { Boost::archive::binary_iarchive ia(ifs); ia >> data; ifs.close(); } } catch (std:exception &e) { Ifs.close(); }
Sometimes it reads the file fine and sometimes it throws one of the following errors.
invalid_signature, Basic_string::resize, or stream error.
Does anyone have an idea why sometimes it works and sometimes it does not work?
a) Is the behavior consistent? i.e. does it yield different behavior for different archives, or can it yield different behavior for the same archive? b) What is data? c) How is the archive created d) Does it help if the archive is destroyed before the stream is closed? In Christ, Steven Watanabe

Hi Steven, Answers to your questions: a) it yields different behavior for the same archive. b) See attached source LegacyMonitorPersistentData.h c) See attached source PersistentData.h d) I have not tried that. I will give this a try. This is what I am testing. I have this archive file ^Press.dat. that was created once by our customer. I try to de-serializing using the loadPersistentData() function and it works sometimes, but about every third try it throw one of the exceptions. Thanks, Robert
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: Tuesday, June 15, 2010 3:44 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading Binary File
AMDG
Robert McCullough wrote:
I am using Boost 1.43.0, Linux 2.6.23, gcc version 4.0.0 on a Freescale PowerPC.
I am reading in a serialized binary file using
Ifstream ifs; try { Ifs.open(filename.c_str(), iso_base::binary | iso_base::in); If(fs.is_open()) { Boost::archive::binary_iarchive ia(ifs); ia >> data; ifs.close(); } } catch (std:exception &e) { Ifs.close(); }
Sometimes it reads the file fine and sometimes it throws one of the following errors.
invalid_signature, Basic_string::resize, or stream error.
Does anyone have an idea why sometimes it works and sometimes it does not work?
a) Is the behavior consistent? i.e. does it yield different behavior for different archives, or can it yield different behavior for the same archive? b) What is data? c) How is the archive created d) Does it help if the archive is destroyed before the stream is closed?
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

AMDG Robert McCullough wrote:
Answers to your questions: a) it yields different behavior for the same archive. b) See attached source LegacyMonitorPersistentData.h c) See attached source PersistentData.h d) I have not tried that. I will give this a try. This is what I am testing. I have this archive file ^Press.dat. that was created once by our customer. I try to de-serializing using the loadPersistentData() function and it works sometimes, but about every third try it throw one of the exceptions.
Okay. What version of Boost are you using? Can you step through basic_binary_iarchive<Archive>::init() in a debugger? It's at boost/archive/impl/basic_binary_archive.ipp line 50. What you ought to see is: l is set to 22. file_signature is set to "serialization::archive" input_library_version is set to 5 "invalid signature" indicates that file_signature is wrong. Some info about the archive that you might want to verify: The platform is big-endian sizeof(size_t) == 4 sizeof(library_version_type) == 1. sizeof(int) == 4 sizeof(long) == 4 sizeof(float) == 4 sizeof(double) == 8 In Christ, Steven Watanabe

Steven, I was able to compile and run my app on Windows 7. Debugging using Visual Studio 2008 and using Boost 1.43.0 with the patch from https://svn.boost.org/trac/boost/ticket/4257 The value of l at line 56 of boost/archive/impl/basic_binary_archive.ipp is I = 369098752; file_signature = "" Line 56: if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { Fails! Line 70: if(file_signature != BOOST_ARCHIVE_SIGNATURE()) is true so, the archive_exception::invalid_signature is thrown on line 73. On my Window 7 PC, sizeof(size_t) == 4 sizeof(library_version_type) could not find definition of library_version_type sizeof(int) == 4 sizeof(long) == 4 sizeof(float) == 4 sizeof(double) == 8 Thanks, Robert
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: Tuesday, June 15, 2010 8:41 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading Binary File
AMDG
Robert McCullough wrote:
Answers to your questions: a) it yields different behavior for the same archive. b) See attached source LegacyMonitorPersistentData.h c) See attached source PersistentData.h d) I have not tried that. I will give this a try. This is what I am testing. I have this archive file ^Press.dat. that was created once by our customer. I try to de-serializing using the loadPersistentData() function and it works sometimes, but about every third try it throw one of the exceptions.
Okay. What version of Boost are you using? Can you step through basic_binary_iarchive<Archive>::init() in a debugger? It's at boost/archive/impl/basic_binary_archive.ipp line 50. What you ought to see is: l is set to 22. file_signature is set to "serialization::archive" input_library_version is set to 5
"invalid signature" indicates that file_signature is wrong.
Some info about the archive that you might want to verify: The platform is big-endian sizeof(size_t) == 4 sizeof(library_version_type) == 1. sizeof(int) == 4 sizeof(long) == 4 sizeof(float) == 4 sizeof(double) == 8
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

AMDG Robert McCullough wrote:
I was able to compile and run my app on Windows 7. Debugging using Visual Studio 2008 and using Boost 1.43.0 with the patch from https://svn.boost.org/trac/boost/ticket/4257
The value of l at line 56 of boost/archive/impl/basic_binary_archive.ipp is I = 369098752;
= 0x16000000 indicating that you're trying to read the archive on a little endian machine, when it was written on a big endian machine.
file_signature = "" Line 56: if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { Fails! Line 70: if(file_signature != BOOST_ARCHIVE_SIGNATURE()) is true so, the archive_exception::invalid_signature is thrown on line 73.
On my Window 7 PC, sizeof(size_t) == 4 sizeof(library_version_type) could not find definition of library_version_type
It's boost::archive::library_version_type defined in boost/archive/basic_archive.hpp
sizeof(int) == 4 sizeof(long) == 4 sizeof(float) == 4 sizeof(double) == 8
In Christ, Steven Watanabe

Steven, Ok, thanks. I was just wondering about that. I guess I will have to go back to debugging it on my embedded PowerPC with gcc and Eclipse. I will try the same tests on the PowerPC. Thanks, Robert
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: Wednesday, June 16, 2010 11:36 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading Binary File
AMDG
Robert McCullough wrote:
I was able to compile and run my app on Windows 7. Debugging using Visual Studio 2008 and using Boost 1.43.0 with the patch from https://svn.boost.org/trac/boost/ticket/4257
The value of l at line 56 of boost/archive/impl/basic_binary_archive.ipp is I = 369098752;
= 0x16000000
indicating that you're trying to read the archive on a little endian machine, when it was written on a big endian machine.
file_signature = "" Line 56: if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { Fails! Line 70: if(file_signature != BOOST_ARCHIVE_SIGNATURE()) is true so, the archive_exception::invalid_signature is thrown on line 73.
On my Window 7 PC, sizeof(size_t) == 4 sizeof(library_version_type) could not find definition of library_version_type
It's boost::archive::library_version_type defined in boost/archive/basic_archive.hpp
sizeof(int) == 4 sizeof(long) == 4 sizeof(float) == 4 sizeof(double) == 8
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Steven, Does the Serialization library support multi-thread application. My application uses boost::archive::binary_iarchive and boost::archive::binary_oarchive to serialize data to/from files in several different threads. I believe this might be happing at the same time. Could this be causing my problem? Thanks, Robert
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: Wednesday, June 16, 2010 11:36 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading Binary File
AMDG
Robert McCullough wrote:
I was able to compile and run my app on Windows 7. Debugging using Visual Studio 2008 and using Boost 1.43.0 with the patch from https://svn.boost.org/trac/boost/ticket/4257
The value of l at line 56 of boost/archive/impl/basic_binary_archive.ipp is I = 369098752;
= 0x16000000
indicating that you're trying to read the archive on a little endian machine, when it was written on a big endian machine.
file_signature = "" Line 56: if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { Fails! Line 70: if(file_signature != BOOST_ARCHIVE_SIGNATURE()) is true so, the archive_exception::invalid_signature is thrown on line 73.
On my Window 7 PC, sizeof(size_t) == 4 sizeof(library_version_type) could not find definition of library_version_type
It's boost::archive::library_version_type defined in boost/archive/basic_archive.hpp
sizeof(int) == 4 sizeof(long) == 4 sizeof(float) == 4 sizeof(double) == 8
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

AMDG Robert McCullough wrote:
Does the Serialization library support multi-thread application. My application uses boost::archive::binary_iarchive and boost::archive::binary_oarchive to serialize data to/from files in several different threads. I believe this might be happing at the same time. Could this be causing my problem?
It's quite possible. Do you know that fstream is thread safe? Can you try just reading the first four bytes of the file and checking them? std::size_t length; ifs.read(&length, 4); assert(length == 0x16); In Christ, Steven Watanabe

Robert McCullough wrote:
Steven,
Does the Serialization library support multi-thread application. My application uses boost::archive::binary_iarchive and boost::archive::binary_oarchive to serialize data to/from files in several different threads.
What could this mean? That multiple threads read/write to the same open archive? Of course this could never make sense. That multiple archives are being used simultaneously by different threads? As far as I know, subject to the following, there should be no problem. a) If serialization code for some class is in a DLL and this DLL is dynamically loaded/unloaded while some other archive is open and being used by a separate thread, there could be a problem. This would be due to the fact that there is global list of types which is updated when a DLL is loaded and/or unloaded. b) xml_iarchives depend upon spirit which is not guarenteed thread-safe. I looked at the spirit code and believe that I selected that part which was thread-safe. But at least one user noted an issue with loading multiple xml_iarchives from separate threads.
I believe this might be happing at the same time. Could this be causing my problem?
This question suggests to me that you're going about addressing your problem in totally the wrong way. I would suggest you make a unit test for your serialization code. Look at the tests in the serialization library for inspiration. This might seem like extra work - but it's not. It saves time. Do the following. a) Make a one or more small test programs which test JUST the serialization of your classes. b) Run these test programs on ALL the archive classes in the the library including text and xml. If your serialization functions are correctly written, the ALL archive classes should work. c) Consider making a separate test program for each class. On my system, anytime I make a change in one class, all tests using that class are automatically recompiled and re-run. This saves huge amounts of wasted time in the future. I seem to recall that one problem is that you were using binary_archive to try to read archives created on a different platform. This is not supported by the binary_archive - and this is clearly stated in the documentation. If you're doing this, this can never work. Robert Ramey
Thanks, Robert

AMDG Robert Ramey wrote:
What could this mean?
That multiple threads read/write to the same open archive? Of course this could never make sense.
In the given code, a new ifstream and archive are created for reading.
That multiple archives are being used simultaneously by different threads? As far as I know, subject to the following, there should be no problem.
a) If serialization code for some class is in a DLL and this DLL is dynamically loaded/unloaded while some other archive is open and being used by a separate thread, there could be a problem. This would be due to the fact that there is global list of types which is updated when a DLL is loaded and/or unloaded.
It's blowing up when trying to read the serialization header. I don't think this has anything to do with the type being serialized.
b) xml_iarchives depend upon spirit which is not guarenteed thread-safe. I looked at the spirit code and believe that I selected that part which was thread-safe. But at least one user noted an issue with loading multiple xml_iarchives from separate threads.
It's a binary archive. In Christ, Steven Watanabe

Steven Watanabe wrote:
a) If serialization code for some class is in a DLL and this DLL is dynamically loaded/unloaded while some other archive is open and being used by a separate thread, there could be a problem. This would be due to the fact that there is global list of types which is updated when a DLL is loaded and/or unloaded.
It's blowing up when trying to read the serialization header. I don't think this has anything to do with the type being serialized.
b) xml_iarchives depend upon spirit which is not guarenteed thread-safe. I looked at the spirit code and believe that I selected that part which was thread-safe. But at least one user noted an issue with loading multiple xml_iarchives from separate threads.
It's a binary archive.
I'm aware of these facts. My real point is that the effort is mis-directed. It's much, much easier and cost-effective to compose components independently proven to be correct than it is to just patch together a bunch of stuff and try to trace backward from the symptoms when it fails. I'm absolutely sure that the amount of effort required to implement my suggestion would be far, far less than the effort so far expended. (I'm not even count your's and my efforts in trying to respond to a post which says (paraphrasing) "My binary serialization doesn't work, what could I be doing wrong?" The uttering of this sentence, reveals the crus of the real problem which is one is going about the task of creating correct software from exactly the wrong end. Robert Ramey

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Thursday, June 17, 2010 12:20 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading BinaryFile
Robert McCullough wrote:
Steven,
Does the Serialization library support multi-thread application. My application uses boost::archive::binary_iarchive and boost::archive::binary_oarchive to serialize data to/from files in several different threads.
What could this mean?
That multiple threads read/write to the same open archive? Of course this could never make sense.
That multiple archives are being used simultaneously by different threads? As far as I know, subject to the following, there should be no problem.
[Robert McCullough] It means that multiple archives are being used simultaneously by different threads. Ok, this seems to work. I removed all the other archives from the threads so that there is only one archive. I still have my problem, so I don't think this is my issue.
a) If serialization code for some class is in a DLL and this DLL is dynamically loaded/unloaded while some other archive is open and being used by a separate thread, there could be a problem. This would be due to the fact that there is global list of types which is updated when a DLL is loaded and/or unloaded.
[Robert McCullough] Ok, I am not using DLL's.
b) xml_iarchives depend upon spirit which is not guarenteed thread-safe. I looked at the spirit code and believe that I selected that part which was thread-safe. But at least one user noted an issue with loading multiple xml_iarchives from separate threads.
[Robert McCullough] Ok. I will keep that in mind if I use xml_iarchives.
I believe this might be happing at the same time. Could this be causing my problem?
This question suggests to me that you're going about addressing your problem in totally the wrong way. I would suggest you make a unit test for your serialization code. Look at the tests in the serialization library for inspiration. This might seem like extra work - but it's not. It saves time. Do the following.
a) Make a one or more small test programs which test JUST the serialization of your classes. b) Run these test programs on ALL the archive classes in the the library including text and xml. If your serialization functions are correctly written, the ALL archive classes should work. c) Consider making a separate test program for each class. On my system, anytime I make a change in one class, all tests using that class are automatically recompiled and re-run. This saves huge amounts of wasted time in the future.
I seem to recall that one problem is that you were using binary_archive to
[Robert McCullough] Ok, thanks for the advice. try
to read archives created on a different platform. This is not supported by the binary_archive - and this is clearly stated in the documentation. If you're doing this, this can never work.
[Robert McCullough] Yes, I realized that this would not work on different platforms. I was just testing my code on different platforms to see if the bug happened on both. Then I realized I could not read the same archive file on both platforms.
Robert Ramey
Thanks, Robert
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Steven, I modified basic_binary_iarchive.ipp with some cout lines for debugging. See attached file. I executed the LoadPersistentData() in the LoadPersistentData.cpp to serialize in my data from the file. The output.txt file shows the output for one Good and two Bad results of executing this function. You can see from the Bad results that the basic_binary_iarchive<Archive>::init() is failing on line : if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { and line if(file_signature != BOOST_ARCHIVE_SIGNATURE()) Do you have any ideas why I would be getting these large numbers for " l "? What does the " input_library_version " indicate? What does input_library_version == 5 mean ? What does input_library_version == 7 mean ? Thanks, Robert
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: Wednesday, June 16, 2010 11:36 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading Binary File
AMDG
Robert McCullough wrote:
I was able to compile and run my app on Windows 7. Debugging using Visual Studio 2008 and using Boost 1.43.0 with the patch from https://svn.boost.org/trac/boost/ticket/4257
The value of l at line 56 of boost/archive/impl/basic_binary_archive.ipp is I = 369098752;
= 0x16000000
indicating that you're trying to read the archive on a little endian machine, when it was written on a big endian machine.
file_signature = "" Line 56: if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { Fails! Line 70: if(file_signature != BOOST_ARCHIVE_SIGNATURE()) is true so, the archive_exception::invalid_signature is thrown on line 73.
On my Window 7 PC, sizeof(size_t) == 4 sizeof(library_version_type) could not find definition of library_version_type
It's boost::archive::library_version_type defined in boost/archive/basic_archive.hpp
sizeof(int) == 4 sizeof(long) == 4 sizeof(float) == 4 sizeof(double) == 8
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Robert McCullough wrote:
basic_binary_iarchive<Archive>::init() is failing on line : if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { and line if(file_signature != BOOST_ARCHIVE_SIGNATURE())
Do you have any ideas why I would be getting these large numbers for " l "?
What does the " input_library_version " indicate?
What does input_library_version == 5 mean ?
What does input_library_version == 7 mean ?
Look at the code in boost_archive.cpp. Comments in the code describe what these numbers mean. Robert Ramey

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Thursday, June 17, 2010 12:22 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading BinaryFile
Robert McCullough wrote:
basic_binary_iarchive<Archive>::init() is failing on line : if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { and line if(file_signature != BOOST_ARCHIVE_SIGNATURE())
Do you have any ideas why I would be getting these large numbers for " l "?
What does the " input_library_version " indicate?
What does input_library_version == 5 mean ?
What does input_library_version == 7 mean ?
Look at the code in boost_archive.cpp. Comments in the code describe what these numbers mean.
[Robert McCullough] I cannot seem to find file boost_archive.cpp.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Robert McCullough wrote:
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Thursday, June 17, 2010 12:22 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading BinaryFile
Robert McCullough wrote:
basic_binary_iarchive<Archive>::init() is failing on line : if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { and line if(file_signature != BOOST_ARCHIVE_SIGNATURE())
Do you have any ideas why I would be getting these large numbers for " l "?
What does the " input_library_version " indicate?
What does input_library_version == 5 mean ?
What does input_library_version == 7 mean ?
Look at the code in boost_archive.cpp. Comments in the code describe what these numbers mean.
[Robert McCullough] I cannot seem to find file boost_archive.cpp.
Hmmm - it's not in [BOOSTROOT]/libs/serialization/src/boost_archive.cpp ? If this file is missing, that would be a serious problem. I don't see how the library could be built without errors if this is missing. Robert Ramey

try using an xml_archive instead. This has extra consistency checking and is helpful for spotting errors. Robert Ramey Robert McCullough wrote:
Hi Steven,
Answers to your questions: a) it yields different behavior for the same archive. b) See attached source LegacyMonitorPersistentData.h c) See attached source PersistentData.h d) I have not tried that. I will give this a try. This is what I am testing. I have this archive file ^Press.dat. that was created once by our customer. I try to de-serializing using the loadPersistentData() function and it works sometimes, but about every third try it throw one of the exceptions.
Thanks, Robert
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: Tuesday, June 15, 2010 3:44 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading Binary File
AMDG
I am using Boost 1.43.0, Linux 2.6.23, gcc version 4.0.0 on a Freescale PowerPC.
I am reading in a serialized binary file using
Ifstream ifs; try { Ifs.open(filename.c_str(), iso_base::binary | iso_base::in); If(fs.is_open()) { Boost::archive::binary_iarchive ia(ifs); ia >> data; ifs.close(); } } catch (std:exception &e) { Ifs.close(); }
Sometimes it reads the file fine and sometimes it throws one of
Robert McCullough wrote: the > > following errors.
invalid_signature, Basic_string::resize, or stream error.
Does anyone have an idea why sometimes it works and sometimes it
does
not work?
a) Is the behavior consistent? i.e. does it yield different behavior for different archives, or can it yield different behavior for the same archive? b) What is data? c) How is the archive created d) Does it help if the archive is destroyed before the stream is closed? > In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi, Robert Thanks for the information. We cannot use an xml_archive because it is too slow for our application. I have used an xml_archive in the past for testing, but right now I am trying to figure out why sometimes I cannot read the binary_archive which was created at a customer's site. Thanks, Robert McCullough
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Wednesday, June 16, 2010 2:22 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading BinaryFile
try using an xml_archive instead. This has extra consistency checking and is helpful for spotting errors.
Robert Ramey
Robert McCullough wrote:
Hi Steven,
Answers to your questions: a) it yields different behavior for the same archive. b) See attached source LegacyMonitorPersistentData.h c) See attached source PersistentData.h d) I have not tried that. I will give this a try. This is what I am testing. I have this archive file ^Press.dat. that was created once by our customer. I try to de-serializing using the loadPersistentData() function and it works sometimes, but about every third try it throw one of the exceptions.
Thanks, Robert
I am using Boost 1.43.0, Linux 2.6.23, gcc version 4.0.0 on a > Freescale PowerPC.
I am reading in a serialized binary file using > > > > Ifstream ifs; > > try > > { Ifs.open(filename.c_str(), iso_base::binary | iso_base::in); If(fs.is_open()) { Boost::archive::binary_iarchive ia(ifs); ia >> data; ifs.close(); } } catch (std:exception &e) { Ifs.close(); }
Sometimes it reads the file fine and sometimes it throws one of
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- > bounces@lists.boost.org] On Behalf Of Steven Watanabe > Sent: Tuesday, June 15, 2010 3:44 PM > To: boost-users@lists.boost.org > Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading Binary > File > > AMDG > > Robert McCullough wrote: the > > following errors.
invalid_signature, Basic_string::resize, or stream error.
Does anyone have an idea why sometimes it works and sometimes it
does > > not work?
a) Is the behavior consistent? i.e. does it yield different behavior for > different archives, or can it yield different behavior for the same archive? b) What is data? c) How is the archive created d) Does it help if the archive is destroyed before the stream is closed? > > In Christ, > Steven Watanabe > >
Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Robert McCullough
-
Robert Ramey
-
Steven Watanabe