[Boost-bugs] [Boost C++ Libraries] #11155: Binary WSerialization throws

Subject: [Boost-bugs] [Boost C++ Libraries] #11155: Binary WSerialization throws
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-03-30 17:48:02


#11155: Binary WSerialization throws
------------------------------+---------------------------
 Reporter: mihai_popescu@… | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost 1.57.0 | Severity: Regression
 Keywords: |
------------------------------+---------------------------
 The Binary WSerialization throws in

 \include\boost\archive\impl\basic_binary_iprimitive.ipp.

 this->This()->load(size);
 if(sizeof(float) != size)
     boost::serialization::throw_exception(
         archive_exception(
             archive_exception::incompatible_native_format,
             "size of float"
         )
     );

 This is reproducible via an existing test
 \boost_1_57_0.zip\boost_1_57_0\libs\uuid\test\test\wserialization.cpp
 which seems it is commented out from the suite:

     # test serializing uuids
     [ run test_serialization.cpp
 ../../serialization/build//boost_serialization ]
     # TODO - This test fails to like with boost_wserialization
     #[ run test_wserialization.cpp
     # ../../serialization/build//boost_serialization
     # ../../serialization/build//boost_wserialization
     # : : : <dependency>../../config/test/all//BOOST_NO_STD_WSTREAMBUF
     #]

 The problem is in
 \include\boost\archive\impl\basic_binary_iarchive.ipp
 Line 110:
         else{
             // version 8+ followed by a zero
             this->This()->m_sb.sbumpc();
         }

 The code works for regular non-wide archives. For warchives it
 incorrectly skips the second byte. The version is always 2 bytes
 regardless of archive type.

 I think an option for a proper fix would binary load the
 input_library_version reading and advancing 2 bytes, similarly with
 the file_signature read. However this way is more involving,
 as a quick workaround I duplicate the code for version < 8.

         else{
             // version 8+ is 2 bytes
             // first byte is the version and the second byte is a zero
             // for non wide strings skip the second byte - zero
             int x1;
             x1 = this->This()->m_sb.sgetc();
             // it's a zero, skip it
             if(0 == x1)
                 this->This()->m_sb.sbumpc();
         }

 Looking at the code in basic_binary_iarchive.ipp seems that binary
 serialization may have worked in Version 7 so I'd say this bug may
 likely be a regression.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11155>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC