Opened 7 years ago

Last modified 5 years ago

#12141 reopened Bugs

XML serialization broken

Reported by: Tony Lewis <tonyelewis@…> Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.61.0 Severity: Regression
Keywords: serialization, xml, regression, tag Cc:

Description

The Boost 1.61.0 beta1 version of serialization has a breaking regression that changes the XML closing tag to &lt;/boost_serialization&gt; rather than </boost_serialization>.

Example code:

#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/nvp.hpp>

#include <iostream>

int main() {
        boost::archive::xml_oarchive oa( std::cerr );
        int bob = 3;
        oa << boost::serialization::make_nvp( "bob", bob );
}

Compiling and running with these commands:

setenv LD_LIBRARY_PATH /opt/boost_1_60_0_gcc_build/lib:/opt/boost_1_61_0_b1_gcc_build/lib
g++ ser_regn.cpp -isystem /opt/boost_1_60_0_gcc_build/include    -L/opt/boost_1_60_0_gcc_build/lib    -l boost_serialization-mt -o ser_regn.1_60_0
g++ ser_regn.cpp -isystem /opt/boost_1_61_0_b1_gcc_build/include -L/opt/boost_1_61_0_b1_gcc_build/lib -l boost_serialization-mt -o ser_regn.1_61_0_b1
./ser_regn.1_60_0
./ser_regn.1_61_0_b1

The 1_60_0 version gives:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="14">
<bob>3</bob>
</boost_serialization>

The 1_61_0_b1 version gives:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="14">
<bob>3</bob>
&lt;/boost_serialization&gt;

Attachments (1)

xml_woarchive_impl.diff (702 bytes ) - added by frank.richter@… 5 years ago.
Patch to fix xml_woarchive writing after last tag

Download all attachments as: .zip

Change History (10)

comment:1 by Robert Ramey, 7 years ago

what compiler, platform, etc. can reproduce this?

comment:2 by Tony Lewis <tonyelewis@…>, 7 years ago

I'm seeing this on both:

g++ (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
GNU libstdc++ version 20151010

...and:

Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
libc++ version 1101

Both are running on:

Ubuntu 15.10
Linux 4.2.0-35-generic #40-Ubuntu SMP Tue Mar 15 22:15:45 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

comment:3 by Robert Ramey, 7 years ago

Resolution: fixed
Status: newclosed

Wow - my tests didn't detect this. I've made the change and tested on my own system and uploaded it to boost. Early tomorrow I'll ask permission to merge into master so it can be included in to the official release of 1.61. I don't know if they'll accept it though.

comment:4 by anonymous, 7 years ago

Great stuff. Thanks very much for addressing this so quickly. Yes - definitely worth getting this test case into the suite.

I think this has got to be a good candidate for them allowing a merge because I'd estimate the cost of keeping this error in would easily outweigh the expected cost of possible problems caused by the change.

Thanks again.

comment:5 by mark.incley@…, 6 years ago

Hi. Using Boost 1.62 Beta 1 and Visual Studio 2015 Update 3, I'm still seeing the exact same issue reported by Colin here: http://lists.boost.org/boost-users/2016/06/86317.php

i.e. the xml file ending with:

</boost_serialization> 

&lt;/boost_serialization&gt;

comment:6 by anonymous, 6 years ago

Resolution: fixed
Status: closedreopened

comment:7 by mark.incley@…, 6 years ago

The problem still in Boost 1.62 Beta 1 (and Beta 2) only occurs with the wide XML archiver (xml_woarchive) and not the narrow one (xml_oarchive), and seems to be due to the difference in behaviour (other than char types) between:

xml_oarchive_impl<Archive>::save(const char * s)

and

xml_woarchive_impl<Archive>::save(const wchar_t * ws)

Mark.

by frank.richter@…, 5 years ago

Attachment: xml_woarchive_impl.diff added

Patch to fix xml_woarchive writing after last tag

comment:8 by frank.richter@…, 5 years ago

Attached patch fixes it for me.

comment:9 by Brian Martin <brian.codemonkey@…>, 5 years ago

Is this still open or been fixed? I'm using boost 1.65 and I'm getting an extra closing tag of &lt;/boost_serialization&gt; at the end of the file. It only does this for xml_woarchive, the narrow archive is fine.

Brian

Note: See TracTickets for help on using tickets.