boost::serialization binary archives not portable?

Hi, I have a problem with boost::serialization in that I cannot transport binary archives between my macbookpro (osx 10.4 latest update) and my dell box at work (ubuntu gutsy with universe). As a test I just serialized a 10-byte binary object. Has anyone else been moving binary archives between different platforms? here are the stacktraces up to the exception throws Moving from ubuntu to osx I get this #7 0x0001bcc8 in boost::throw_exception<boost::archive::archive_exception> () at libs/serialization/src/basic_serializer_map.cpp:52 #8 0x0000f104 in boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::init (this=0xbfffeec8) at ./boost/archive/impl/basic_binary_iarchive.ipp:54 #9 0x0000f20b in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::init (this=0xbfffeec8, flags=0) at ./boost/archive/binary_iarchive_impl.hpp:51 #10 0x0000f4a4 in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::binary_iarchive_impl (this=0xbfffeec8, is=@0xbfffec30, flags=0) at ./boost/archive/binary_iarchive_impl.hpp:80 #11 0x0001862d in boost::archive::binary_iarchive::binary_iarchive () at libs/serialization/src/basic_serializer_map.cpp:52 #12 0x00002bda in main () the other direction: #4 0x00002b41bac2d773 in std::terminate () from /usr/lib/libstdc++.so.6 #5 0x00002b41bac2d85a in __cxa_throw () from /usr/lib/libstdc++.so.6 #6 0x00002b41babc944a in std::__throw_length_error () from /usr/lib/libstdc++.so.6 #7 0x00002b41bac0cda2 in std::string::resize () from /usr/lib/libstdc++.so.6 #8 0x00000000004339de in boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive, char, std::char_traits<char> >::load (this=0x7ffff015afe0, s=@0x7ffff015ad50) at ./boost/archive/impl/basic_binary_iprimitive.ipp:96 #9 0x0000000000433a23 in boost::archive::load_access::load_primitive<boost::archive::binary_iarchive, std::string> (ar=@0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/iserializer.hpp:96 #10 0x0000000000433a43 in boost::archive::detail::load_non_pointer_type<boost::archive::binary_iarchive, std::string>::load_primitive::invoke (ar=@0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/iserializer.hpp:339 #11 0x0000000000433a63 in boost::archive::detail::load_non_pointer_type<boost::archive::binary_iarchive, std::string>::invoke (ar=@0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/iserializer.hpp:414 #12 0x0000000000433a83 in boost::archive::load<boost::archive::binary_iarchive, std::string> (ar=@0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/iserializer.hpp:561 #13 0x0000000000433aae in boost::archive::detail::common_iarchive<boost::archive::binary_iarchive>::load_override<std::string> (this=0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/common_iarchive.hpp:59 #14 0x0000000000433ad3 in boost::archive::array::iarchive<boost::archive::binary_iarchive>::load_override<std::string> (this=0x7ffff015afd0, x=@0x7ffff015ad50, version=0) at ./boost/archive/array/iarchive.hpp:122 #15 0x0000000000433afb in boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<std::string> (this=0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/basic_binary_iarchive.hpp:62 #16 0x0000000000433b23 in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::load_override<std::string> (this=0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/binary_iarchive_impl.hpp:45 #17 0x0000000000433b50 in boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><std::string> (this=0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/interface_iarchive.hpp:63 #18 0x0000000000433b87 in boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::init (this=0x7ffff015afd0) at ./boost/archive/impl/basic_binary_iarchive.ipp:52 #19 0x000000000040c8ee in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::init (this=0x7ffff015afd0, flags=0) at ./boost/archive/binary_iarchive_impl.hpp:51 #20 0x000000000040c971 in binary_iarchive_impl (this=0x7ffff015afd0, is=@0x7ffff015b790, flags=0) at ./boost/archive/binary_iarchive_impl.hpp:80 #21 0x000000000040c9db in boost::archive::binary_iarchive::binary_iarchive () at ./boost/archive/codecvt_null.hpp:48 #22 0x0000000000405518 in main () daniel

Daniel Oberhoff wrote:
I have a problem with boost::serialization in that I cannot transport binary archives between my macbookpro (osx 10.4 latest update) and my dell box at work (ubuntu gutsy with universe). As a test I just serialized a 10-byte binary object. Has anyone else been moving binary archives between different platforms?
Hi Daniel, the binary archive that comes with boost::serialization generates platform dependent files. If you are interested in cross-platform data exchange you'd have to use a text archive or try my portable binary archive which you find at http://www.boost-consulting.com/vault in the serialization folder. I'd be very much interested if it works for your setting - which is 64-bit PowerPC and 32-bit x86? Just try it out and share your experience. Christian Pfligersdorffer

Unfortunately, recent changes in binary_?archive break any archive classes derived from it - this includes the portable binary demo included in the package and probably other archives as well. Good news is that, with the help of a corporate sponser, I've made a new implemention which doesn't derive from binary_?archive and has been tested on a variety of platforms of varying integer sizes and endian-ness. I expect it will be included in a future version of boost serialization. Also, the purpose of the current demo was to demonstrate creation of a new archive class through derivation from an existing one. So, I'll have to replace this with another example and and update the documentation accordingly. Robert Ramey Pfligersdorffer, Christian wrote:
Daniel Oberhoff wrote:
I have a problem with boost::serialization in that I cannot transport binary archives between my macbookpro (osx 10.4 latest update) and my dell box at work (ubuntu gutsy with universe). As a test I just serialized a 10-byte binary object. Has anyone else been moving binary archives between different platforms?
Hi Daniel,
the binary archive that comes with boost::serialization generates platform dependent files. If you are interested in cross-platform data exchange you'd have to use a text archive or try my portable binary archive which you find at http://www.boost-consulting.com/vault in the serialization folder.
I'd be very much interested if it works for your setting - which is 64-bit PowerPC and 32-bit x86? Just try it out and share your experience.
Christian Pfligersdorffer

On 28 Nov 2007, at 17:32, Robert Ramey wrote:
Unfortunately, recent changes in binary_?archive break any archive classes derived from it - this includes the portable binary demo included in the package and probably other archives as well.
Robert, could you please send me a single example, outside of your portable binary archive demo that would need to be updated, where the array extensions break anything? Matthias

It would be any archive which alters the of bytes from that used by the native machine. The implementation of portable binary archive (which had/has) a few issues anyway, renders the byte stream in an manner independent of the int size and endian-ness. So it fails. I never thought about this until I came upon it by accident. So I have no idea when it will come up again. What bothers me more about it is that now I can derive from a known archive according to the documentation, and have an implementation which full fills the stated requirements but won't work. I suspect that there needs to be some additional concept added to the binary_?archives that other archive classes don't have. But truth is, I really haven't considered it detail. I was sort of annoyed that the example used to illustrate derivation from an existing archive has to be redone. as I didn't find out about it until recently, so the next release includes a demo and documentation that doesn't work without any real time to fix it. Robert Ramey Matthias Troyer wrote:
On 28 Nov 2007, at 17:32, Robert Ramey wrote:
Unfortunately, recent changes in binary_?archive break any archive classes derived from it - this includes the portable binary demo included in the package and probably other archives as well.
Robert, could you please send me a single example, outside of your portable binary archive demo that would need to be updated, where the array extensions break anything?
Matthias

binary archives are designed to be fastest implementation of the archive concept. They are not portable. Currently, if you need portability, you'll have to use a text based archive such as text_?archive, or xml_archive. Robert Ramey Daniel Oberhoff wrote:
Hi,
I have a problem with boost::serialization in that I cannot transport binary archives between my macbookpro (osx 10.4 latest update) and my dell box at work (ubuntu gutsy with universe). As a test I just serialized a 10-byte binary object. Has anyone else been moving binary archives between different platforms?
here are the stacktraces up to the exception throws
Moving from ubuntu to osx I get this
#7 0x0001bcc8 in boost::throw_exception<boost::archive::archive_exception> () at libs/serialization/src/basic_serializer_map.cpp:52 #8 0x0000f104 in boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::init (this=0xbfffeec8) at ./boost/archive/impl/basic_binary_iarchive.ipp:54 #9 0x0000f20b in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::init (this=0xbfffeec8, flags=0) at ./boost/archive/binary_iarchive_impl.hpp:51 #10 0x0000f4a4 in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::binary_iarchive_impl (this=0xbfffeec8, is=@0xbfffec30, flags=0) at ./boost/archive/binary_iarchive_impl.hpp:80 #11 0x0001862d in boost::archive::binary_iarchive::binary_iarchive () at libs/serialization/src/basic_serializer_map.cpp:52 #12 0x00002bda in main ()
the other direction:
#4 0x00002b41bac2d773 in std::terminate () from /usr/lib/libstdc++.so.6 #5 0x00002b41bac2d85a in __cxa_throw () from /usr/lib/libstdc++.so.6 #6 0x00002b41babc944a in std::__throw_length_error () from /usr/lib/libstdc++.so.6 #7 0x00002b41bac0cda2 in std::string::resize () from /usr/lib/libstdc++.so.6 #8 0x00000000004339de in boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive, char, std::char_traits<char> >::load (this=0x7ffff015afe0, s=@0x7ffff015ad50) at ./boost/archive/impl/basic_binary_iprimitive.ipp:96 #9 0x0000000000433a23 in boost::archive::load_access::load_primitive<boost::archive::binary_iarchive, std::string> (ar=@0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/iserializer.hpp:96 #10 0x0000000000433a43 in
boost::archive::detail::load_non_pointer_type<boost::archive::binary_iarchive, std::string>::load_primitive::invoke (ar=@0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/iserializer.hpp:339 #11 0x0000000000433a63 in boost::archive::detail::load_non_pointer_type<boost::archive::binary_iarchive, std::string>::invoke (ar=@0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/iserializer.hpp:414 #12 0x0000000000433a83 in boost::archive::load<boost::archive::binary_iarchive, std::string> (ar=@0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/iserializer.hpp:561 #13 0x0000000000433aae in boost::archive::detail::common_iarchive<boost::archive::binary_iarchive>::load_override<std::string> (this=0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/common_iarchive.hpp:59 #14 0x0000000000433ad3 in boost::archive::array::iarchive<boost::archive::binary_iarchive>::load_override<std::string> (this=0x7ffff015afd0, x=@0x7ffff015ad50, version=0) at ./boost/archive/array/iarchive.hpp:122 #15 0x0000000000433afb in boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<std::string> (this=0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/basic_binary_iarchive.hpp:62 #16 0x0000000000433b23 in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::load_override<std::string> (this=0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/binary_iarchive_impl.hpp:45 #17 0x0000000000433b50 in boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><std::string> (this=0x7ffff015afd0, t=@0x7ffff015ad50) at ./boost/archive/detail/interface_iarchive.hpp:63 #18 0x0000000000433b87 in boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::init (this=0x7ffff015afd0) at ./boost/archive/impl/basic_binary_iarchive.ipp:52 #19 0x000000000040c8ee in boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::init (this=0x7ffff015afd0, flags=0) at ./boost/archive/binary_iarchive_impl.hpp:51 #20 0x000000000040c971 in binary_iarchive_impl (this=0x7ffff015afd0, is=@0x7ffff015b790, flags=0) at ./boost/archive/binary_iarchive_impl.hpp:80 #21 0x000000000040c9db in boost::archive::binary_iarchive::binary_iarchive () at ./boost/archive/codecvt_null.hpp:48 #22 0x0000000000405518 in main ()
daniel
participants (4)
-
Daniel Oberhoff
-
Matthias Troyer
-
Pfligersdorffer, Christian
-
Robert Ramey