Boost C++ Libraries: Ticket #13354: xml_iarchive destructor calls abort() https://svn.boost.org/trac10/ticket/13354 <p> In the following Unit Test from VS2017 15.5.2 with Boost 1.66.0 from vcpkg, boost::archive::xml_iarchive() is successfully used to load an integer. When it goes out of scope, its destructor calls abort(). </p> <pre class="wiki">#include "stdafx.h" #include "CppUnitTest.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; #include &lt;boost/archive/archive_exception.hpp&gt; #include &lt;boost/serialization/variant.hpp&gt; #include &lt;boost/archive/xml_iarchive.hpp&gt; #include &lt;boost/archive/xml_oarchive.hpp&gt; #include &lt;boost/serialization/split_member.hpp&gt; namespace UtilityLibTest { class XmlArchiveTest { public: XmlArchiveTest() { m_value = 4; } int Value() const { return m_value; } void Value(const int v) { m_value = v; } private: friend class boost::serialization::access; void load(boost::archive::xml_iarchive &amp; ar, unsigned int version) { ar &amp; BOOST_SERIALIZATION_NVP(m_value); } void save(boost::archive::xml_oarchive &amp; ar, unsigned int version) const { ar &amp; BOOST_SERIALIZATION_NVP(m_value); } BOOST_SERIALIZATION_SPLIT_MEMBER() protected: int m_value; }; TEST_CLASS(UnitTest1) { public: TEST_METHOD(XmlArchive_SaveLoad) { XmlArchiveTest store; // save block std::stringstream xml(std::stringstream::out); boost::archive::xml_oarchive archive(xml); archive &amp; BOOST_SERIALIZATION_NVP(store); xml.flush(); auto xml1 = xml.str(); store.Value(234); // load block std::stringstream xml2; xml2 &lt;&lt; xml1; boost::archive::xml_iarchive archive2(xml2); archive2 &amp; BOOST_SERIALIZATION_NVP(store); Assert::AreEqual(4, store.Value(), L"4 != store.Value"); } }; } </pre><p> Call stack </p> <pre class="wiki">&gt; ucrtbased.dll!issue_debug_notification(const wchar_t * const message) Line 28 C++ Non-user code. Symbols loaded. ucrtbased.dll!__acrt_report_runtime_error(const wchar_t * message) Line 154 C++ Non-user code. Symbols loaded. ucrtbased.dll!abort() Line 51 C++ Non-user code. Symbols loaded. ucrtbased.dll!terminate() Line 59 C++ Non-user code. Symbols loaded. vcruntime140d.dll!FindHandler(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, _CONTEXT * pContext, void * pDC, const _s_FuncInfo * pFuncInfo, unsigned char recursive, int CatchDepth, EHRegistrationNode * pMarkerRN) Line 627 C++ Non-user code. Symbols loaded. vcruntime140d.dll!__InternalCxxFrameHandler(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, _CONTEXT * pContext, void * pDC, const _s_FuncInfo * pFuncInfo, int CatchDepth, EHRegistrationNode * pMarkerRN, unsigned char recursive) Line 347 C++ Non-user code. Symbols loaded. vcruntime140d.dll!__CxxFrameHandler(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, void * pContext, void * pDC) Line 219 C++ Non-user code. Symbols loaded. ntdll.dll!ExecuteHandler2@20() Unknown Non-user code. Symbols loaded. ntdll.dll!ExecuteHandler@20() Unknown Non-user code. Symbols loaded. ntdll.dll!_KiUserExceptionDispatcher@8() Unknown Non-user code. Symbols loaded. KernelBase.dll!_RaiseException@16() Unknown Non-user code. Symbols loaded. vcruntime140d.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 136 C++ Non-user code. Symbols loaded. boost_serialization-vc141-mt-gd-x32-1_66.dll!0fe82f45() Unknown No symbols loaded. [Frames below may be incorrect and/or missing, no symbols loaded for boost_serialization-vc141-mt-gd-x32-1_66.dll] Annotated Frame boost_serialization-vc141-mt-gd-x32-1_66.dll!0fec45ad() Unknown No symbols loaded. boost_serialization-vc141-mt-gd-x32-1_66.dll!0fec72fc() Unknown No symbols loaded. boost_serialization-vc141-mt-gd-x32-1_66.dll!0fec7d33() Unknown No symbols loaded. UnitTestsUtilityLib.dll!boost::archive::xml_iarchive::~xml_iarchive() Line 129 C++ Symbols loaded. UnitTestsUtilityLib.dll!UtilityLibTest::UnitTest1::XmlArchive_SaveLoad() Line 72 C++ Symbols loaded. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13354 Trac 1.4.3 anonymous Sat, 13 Jan 2018 17:54:49 GMT <link>https://svn.boost.org/trac10/ticket/13354#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13354#comment:1</guid> <description> <p> I am having the same problem. I am loading a polymorphic object from an xml archive like this: </p> <div class="wiki-code"><div class="code"><pre><span class="n">std</span><span class="o">::</span><span class="n">ifstream</span> <span class="n">file</span><span class="p">(</span><span class="n">filename</span><span class="p">);</span> <span class="n">boost</span><span class="o">::</span><span class="n">archive</span><span class="o">::</span><span class="n">xml_iarchive</span> <span class="n">iarchive</span><span class="p">(</span><span class="n">file</span><span class="p">);</span> <span class="n">Preferences</span> <span class="o">*</span> <span class="n">ptr</span><span class="p">;</span> <span class="n">iarchive</span> <span class="o">&gt;&gt;</span> <span class="n">boost</span><span class="o">::</span><span class="n">serialization</span><span class="o">::</span><span class="n">make_nvp</span><span class="p">(</span><span class="s">&quot;preferences&quot;</span><span class="p">,</span> <span class="n">ptr</span><span class="p">);</span> <span class="k">return</span> <span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o">&lt;</span><span class="n">Preferences</span><span class="o">&gt;</span><span class="p">(</span><span class="n">ptr</span><span class="p">);</span> </pre></div></div><p> and it crashes after successfully reading the object. </p> <p> It works with Boost 1.65. I am using GCC 6.4 on NixOS. </p> </description> <category>Ticket</category> </item> <item> <author>steto84@…</author> <pubDate>Fri, 26 Jan 2018 10:50:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13354#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13354#comment:2</guid> <description> <p> seems that the problem is due to the following portion of code in basic_xml_grammar.ipp: </p> <pre class="wiki">if(is.fail()){ boost::serialization::throw_exception( boost::archive::archive_exception( archive_exception::input_stream_error, std::strerror(errno) ) ); } </pre><p> reverting the file to the previous version seems to solve the problem: </p> <pre class="wiki"> if(is.fail()){ return false; } </pre> </description> <category>Ticket</category> </item> <item> <author>Frédéric Devernay <frederic.devernay@…></author> <pubDate>Sat, 17 Feb 2018 14:55:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13354#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13354#comment:3</guid> <description> <p> probably a duplicate of <a class="new ticket" href="https://svn.boost.org/trac10/ticket/13400" title="#13400: Bugs: boost::archive::xml_iarchive Exception in destructor: &#34;input stream ... (new)">#13400</a> </p> </description> <category>Ticket</category> </item> <item> <author>Frédéric Devernay <frederic.devernay@…></author> <pubDate>Sat, 17 Feb 2018 15:31:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13354#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13354#comment:4</guid> <description> <p> ok, the problem seems to be that the end tag &lt;/boost_serialization&gt; is missing. </p> <p> try to apply the suggestion from <a class="ext-link" href="http://boost.2283326.n4.nabble.com/the-boost-xml-serialization-to-a-stringstream-does-not-have-an-end-tag-td2580772.html"><span class="icon">​</span>http://boost.2283326.n4.nabble.com/the-boost-xml-serialization-to-a-stringstream-does-not-have-an-end-tag-td2580772.html</a> </p> <p> enclose the xml_oarchive in its own scope, so that its destructor is called before calling xml.str(); </p> <p> maybe boost could be more tolerant in this case, and not choke if the end tag is missing? </p> </description> <category>Ticket</category> </item> </channel> </rss>