[Serialization] Need help with binary archive deserialization error

Hi, I just ran into an issue with serialization which is very peculiar. When serializing a complex class structure to an archive all goes well without errors. However, when trying to read back the data it works with all xml and text archive types, but when using binary archives I get an archive exception while loading. The exception occurs while loading an array of 3 doubles. From what I can make up out of the code, the archive says there are 20 bytes to load, while the library expects 24. Apparently I'm doing something that has no effect for text-based serialization, but does for binary. Since I didn't find any posts or tickets for this issue I assume I have made a mistake somewhere, only I have been looking for hours and cannot seem to find it. So any suggestions on where to look would be welcome, even the obvious ones ;-) Regards, George van Venrooij

George van Venrooij wrote:
Apparently I'm doing something that has no effect for text-based serialization, but does for binary. Since I didn't find any posts or tickets for this issue I assume I have made a mistake somewhere, only I have been looking for hours and cannot seem to find it. So any suggestions on where to look would be welcome, even the obvious ones ;-)
Hi, Can you provide a small example that reproduces the problem? This would be the place to start. The problem does not sound familiar. -t

troy d. straszheim wrote:
George van Venrooij wrote:
Apparently I'm doing something that has no effect for text-based serialization, but does for binary. Since I didn't find any posts or tickets for this issue I assume I have made a mistake somewhere, only I have been looking for hours and cannot seem to find it. So any suggestions on where to look would be welcome, even the obvious ones ;-)
Hi,
Can you provide a small example that reproduces the problem? This would be the place to start. The problem does not sound familiar.
What boost version(s) were used to write/read the archive? There was a change somewhere between 1.33 and 1.37 that caused incompatibility with binary archives and vectors of built-in data types. There are some optimizations that only come into play with vectors/arrays of built-ins. Jeff

double check that the stream is opened with ios::binary Robert Ramey George van Venrooij wrote:
Hi,
I just ran into an issue with serialization which is very peculiar. When serializing a complex class structure to an archive all goes well without errors.
However, when trying to read back the data it works with all xml and text archive types, but when using binary archives I get an archive exception while loading.
The exception occurs while loading an array of 3 doubles. From what I can make up out of the code, the archive says there are 20 bytes to load, while the library expects 24.
Apparently I'm doing something that has no effect for text-based serialization, but does for binary. Since I didn't find any posts or tickets for this issue I assume I have made a mistake somewhere, only I have been looking for hours and cannot seem to find it. So any suggestions on where to look would be welcome, even the obvious ones ;-) Regards,
George van Venrooij
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Robert Ramey wrote:
double check that the stream is opened with ios::binary
Robert Ramey
I knew it was something obvious and indeed this was my problem. While making my code as "archive-independent" as possible, I somewhere lost the open_mode flags. Thanks a lot, George van Venrooij
participants (4)
-
George van Venrooij
-
Jeff Flinn
-
Robert Ramey
-
troy d. straszheim