Boost C++ Libraries: Ticket #5553: Access violation caused by boost::unit_test::make_test_case on Windows https://svn.boost.org/trac10/ticket/5553 <p> The unit test main application built in DEBUG mode generates access violation with non debug version of Boost shared libraries on Windows platform. </p> <p> Steps to reproduce: </p> <ul><li>Test file: <div class="wiki-code"><div class="code"><pre><span class="cp">#define BOOST_TEST_MODULE &quot;Test&quot;</span> <span class="cp">#include</span> <span class="cpf">&lt;boost/test/unit_test.hpp&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="p">;</span> <span class="n">BOOST_AUTO_TEST_SUITE</span><span class="p">(</span><span class="n">Suite</span><span class="p">)</span> <span class="n">BOOST_AUTO_TEST_CASE</span><span class="p">(</span><span class="n">Case</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span> <span class="n">BOOST_AUTO_TEST_SUITE_END</span><span class="p">()</span> </pre></div></div></li><li> Compile with Visual C++ 2010 in DEBUG mode having the following defines enabled: <pre class="wiki">BOOST_ALL_DYN_LINK BOOST_ALL_NO_LIB </pre></li><li>Link with the <em>non debug</em> versions of Boost DLLs taken from the [boostpro.com] website (version 1.46.1 or 1.44 for example) </li><li>Run the program </li></ul><p> Expected result: </p> <pre class="wiki">Running 1 test cases... *** No errors detected </pre><p> Actual result: the program will crash in <code>msvcr100.dll</code> in <code>memcpy</code> function with illegal addresses. The callstack: </p> <pre class="wiki">msvcr100.dll!memcpy(unsigned char * dst, unsigned char * src, unsigned long count) Line 311 boost_unit_test_framework-vc100-mt-1_44.dll!10002e29() [Frames below may be incorrect and/or missing, no symbols loaded for boost_unit_test_framework-vc100-mt-1_44.dll] boost_unit_test_framework-vc100-mt-1_44.dll!1003298f() boost_unit_test_framework-vc100-mt-1_44.dll!10032a9d() boost_utf.exe!boost::unit_test::make_test_case(const boost::unit_test::callback0&lt;boost::unit_test::ut_detail::unused&gt; &amp; test_func, boost::unit_test::basic_cstring&lt;char const &gt; tc_name) Line 255 + 0x8d bytes </pre><p> <strong>Note:</strong> </p> <ul><li>The program linked with the DEBUG version of the Boost DLLs works properly. It seems that Boost.Test module generates different codepaths and the Debug and non debug versions of <em>the DLLs are not functionally compatible</em>. </li><li>On Linux this issue does not exist. The DEBUG version of the application works well with the non debug version of boost_unit_test_framework shared object files. </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5553 Trac 1.4.3 Gennadiy Rozental Mon, 17 Oct 2011 04:48:51 GMT <link>https://svn.boost.org/trac10/ticket/5553#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5553#comment:1</guid> <description> <p> Why don't you use debug version of UTF? </p> </description> <category>Ticket</category> </item> <item> <author>Balint SZENTE <balint@…></author> <pubDate>Mon, 17 Oct 2011 17:30:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5553#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5553#comment:2</guid> <description> <p> Actually that's what I'm doing now. </p> <p> To answer your question... I usually use release version of 3rd party libraries when I develop a program, because I'm fond of <em>production</em> builds, not the debug ones. However, I realize that Boost is massively header implemented making the compiler's job significantly harder. </p> <p> I made the bug report to notify this behavior with Microsoft Visual C++, because I could not decide whether this is <em>normal</em> or not, taking into account the fact that on Linux and Max OS X they work well. I did not expected the debug and release builds to be incompatible in such a way that they might result even in crash. Ideally they should be perfectly interchangeable from ABI point of view. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gennadiy Rozental</dc:creator> <pubDate>Mon, 05 Nov 2012 02:10:43 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5553#comment:3 https://svn.boost.org/trac10/ticket/5553#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I do not see anything for us to fix here. </p> Ticket andrepuel@… Sat, 05 Jan 2013 05:22:16 GMT <link>https://svn.boost.org/trac10/ticket/5553#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5553#comment:4</guid> <description> <p> I am using Microsoft Visual Studio 2012 Ultimate and boost 1.52.0. </p> <p> I've compiled boost myself only in release mode. If I compile my tests with debug mode I get the same access violation on make_test_case. </p> <p> If this is the intended behavior I suggest some kind of warning or error if someone tries to use release dll on debug compiled test, because I have had a hard time trying to figure out what was causing the access violation. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 05 Jan 2013 05:22:51 GMT</pubDate> <title>status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/5553#comment:5 https://svn.boost.org/trac10/ticket/5553#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.44.0</span> → <span class="trac-field-new">Boost 1.52.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> Ticket Raffi Enficiaud Sun, 28 Dec 2014 00:23:05 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5553#comment:6 https://svn.boost.org/trac10/ticket/5553#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> The behaviour is well known on Windows: the test module and the boost.test dll should link to the same CRT (Visual C and C++ dll), otherwise they won't use the same heap for instance, which leads to the crashes you describe. This is simply because the API of boost.test contains objects that are not POD. This will be mentionned in the documentation. </p> Ticket