Boost C++ Libraries: Ticket #12913: Undefined behaviour in serialization library https://svn.boost.org/trac10/ticket/12913 <p> Hi Robert, </p> <p> while testing multiprecision with clang's sanitizers I found some undefined behaviour in the serialization lib. The issue can be seen by running serialization's own tests with undefined-behaviour sanitizer turned on - in fact nearly all the tests fail, but most of the failures look like issues with the tests rather than the library. However building test_binary_xml_archive with clang++ -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=undefined results in: </p> <pre class="wiki">../../../boost/archive/detail/interface_oarchive.hpp:47:16: runtime error: downcast of address 0x7ffd0a934990 which does not point to an object of type 'boost::archive::xml_oarchive' 0x7ffd0a934990: note: object is of type 'boost::archive::xml_oarchive_impl&lt;boost::archive::xml_oarchive&gt;' fd 7f 00 00 78 ae d3 9c d6 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'boost::archive::xml_oarchive_impl&lt;boost::archive::xml_oarchive&gt;' SUMMARY: AddressSanitizer: undefined-behavior ../../../boost/archive/detail/interface_oarchive.hpp:47:16 in </pre><p> Which looks like a genuine issue to me. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12913 Trac 1.4.3 Robert Ramey Thu, 04 May 2017 16:12:02 GMT status changed https://svn.boost.org/trac10/ticket/12913#comment:1 https://svn.boost.org/trac10/ticket/12913#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> "most of the failures look like issues with the tests" and examples as well. </p> <p> Unfortunately, when making the tests and examples, I totally ignored the issue of object lifetime. Actually it should be addressed in the documentation itself since de-serialization of a pointer creates a new object which may be without an owner. It's odd that no one has complained about this. I sometimes wonder if this causes problems for some people. In any case, it prevents me from running the "sanitizers" which I would have liked to be able to do. Making alterations to support this would take a very large amount of time which is hard to justify for the serialization library these days. I'm wondering when it will be replaced. </p> <p> This particular error is kind of interesting. According to the message, the complaint is in trying to downcast an object of type xml_oarchive_impl&lt;xml_oarchive&gt; to an object of type xml_oarchive. But I'm quite sure that xml_oarchive has xml_oarchive_impl&lt;xml_oarchive&gt; as a base class. So I can't really understand the message and I'm not really sure what to do about it - if anything. </p> <p> Thanks for pointing this out - I'll leave this open in case I stumble upon something which sheds light on it. </p> Ticket