Boost C++ Libraries: Ticket #12441: Crash in Boost.Test 1.61 https://svn.boost.org/trac10/ticket/12441 <p> We have switched from boost 1.59 to 1.61 and I observe strange crashes when trying to run unit tests. I manage to reproduce it with a trivial example which has no used-added code, only Boost.Test stuff. This is observed with g++ 4.9.3 on Scientific Linux 6 with glibc 2.12. </p> <p> Here is an example: </p> <pre class="wiki">% cat unit_test.cc #define BOOST_TEST_MODULE UnitTest #include &lt;boost/test/included/unit_test.hpp&gt; BOOST_AUTO_TEST_CASE(Test1) { } % g++ --version g++ (GCC) 4.9.3 % BOO=/path/to/boost/1.61.0 % g++ -std=c++11 -o unit_test -fPIC unit_test.cc -I$BOO/include/boost-1_61 -L$BOO/lib -lboost_unit_test_framework-gcc49-mt-1_61 -lboost_timer-gcc49-mt-1_61 -lboost_system-gcc49-mt-1_61 -lboost_chrono-gcc49-mt-1_61 -Wl,--rpath=$BOO/lib % ./unit_test Running 1 test case... *** No errors detected *** glibc detected *** ./unit_test: double free or corruption (!prev): 0x0000000001ca4c70 *** ======= Backtrace: ========= /lib64/libc.so.6[0x33cfe75f3e] /lib64/libc.so.6[0x33cfe78dd0] /lib64/libc.so.6(__cxa_finalize+0x9d)[0x33cfe35e7d] /afs/cern.ch/sw/lcg/releases/LCG_85/Boost/1.61.0/x86_64-slc6-gcc49-opt//lib/libboost_unit_test_framework-gcc49-mt-1_61.so.1.61.0(+0x3b046)[0x7feba3c17046] ======= Memory map: ======== ................... </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12441 Trac 1.4.3 Andy Salnikov <a_salnikov@…> Tue, 06 Sep 2016 22:31:49 GMT <link>https://svn.boost.org/trac10/ticket/12441#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12441#comment:1</guid> <description> <p> I did some debugging and I think this is caused by double-delete of some global objects, in particular global strings defined in <code>unit_test_parameters.ipp</code> file such as <code>boost::unit_test::runtime_config::HELP</code>. That file is included in other places and it is compiled into <code>libboost_unit_test_framework.so</code> and also into application object file. This causes constructor of thaose global object being called twice, once from <code>libboost_unit_test_framework.so</code> globals initialization, and once from application globals initialization. This also causes destructor of these objects called twice during global destruction. </p> <p> I'm not sure whether this is issue specific to g++ version or glibc version, I'm not sure why this issue was not discovered by anybody yet. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 07 Sep 2016 02:40:20 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/12441#comment:2 https://svn.boost.org/trac10/ticket/12441#comment:2 <ul> <li><strong>owner</strong> set to <span class="trac-author">Gennadiy Rozental</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">test</span> </li> </ul> Ticket Andy Salnikov <a_salnikov@…> Wed, 07 Sep 2016 19:32:30 GMT <link>https://svn.boost.org/trac10/ticket/12441#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12441#comment:3</guid> <description> <p> I made another test with the same code (above) on different platform: </p> <ul><li>boost 1.60 </li><li>CentOS 7 </li><li>gcc 4.8.5 </li></ul><p> With this setup instead of glibc complaints I see SEGV crash, stack from this crash: </p> <pre class="wiki">Program received signal SIGSEGV, Segmentation fault. 0x00007ffff69b8aad in malloc_consolidate () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff69b8aad in malloc_consolidate () from /lib64/libc.so.6 #1 0x00007ffff69b9ec6 in _int_free () from /lib64/libc.so.6 #2 0x0000000000476c92 in void boost::checked_array_delete&lt;char&gt;(char*) () #3 0x00000000004697c9 in boost::scoped_array&lt;char&gt;::~scoped_array() () #4 0x00000000004596fa in boost::execution_monitor::~execution_monitor() () #5 0x00000000004697e4 in boost::unit_test::unit_test_monitor_t::~unit_test_monitor_t() () #6 0x00007ffff69761da in __cxa_finalize () from /lib64/libc.so.6 #7 0x00007ffff7b6db63 in __do_global_dtors_aux () from /u2/salnikov/lsstsw/stack/Linux64/boost/1.60.lsst1/lib/libboost_unit_test_framework.so.1.60.0 #8 0x00007fffffffdd70 in ?? () #9 0x00007ffff7deaa1a in _dl_fini () from /lib64/ld-linux-x86-64.so.2 </pre><p> which looks pretty much the same globals destruction issue, except his happens not is string destructors but in some scoped array destructor. </p> </description> <category>Ticket</category> </item> <item> <author>Andy Salnikov <a_salnikov@…></author> <pubDate>Wed, 07 Sep 2016 21:47:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12441#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12441#comment:4</guid> <description> <p> Sorry, I think this is my own fault. Our build system has migrated to a different setup and new build rules started adding <code>-lboost_unit_test_framework</code> to the link and we did not have <code>#define BOOST_TEST_DYN_LINK</code> in our tests. I should have compared it to what our old build system did, instead I wasted my own and everyone's time trying to debug it. The answer is of course that we should not do <code>-lboost_unit_test_framework</code> without <code>BOOST_TEST_DYN_LINK</code> which is clear if one reads documentation. Sorry again, this can be closed. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Wed, 21 Sep 2016 07:47:58 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/12441#comment:5 https://svn.boost.org/trac10/ticket/12441#comment:5 <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">invalid</span> </li> </ul> <p> Great, thanks for having invested time in tracking this down. I'm closing the ticket then. </p> Ticket erenon2@… Thu, 05 Apr 2018 12:06:20 GMT <link>https://svn.boost.org/trac10/ticket/12441#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12441#comment:6</guid> <description> <p> It also happens if one source file assumes dynamically linked boost test: </p> <pre class="wiki">#define BOOST_TEST_DYN_LINK #include &lt;boost/test/unit_test.hpp&gt; </pre><p> while the other assumes header-only boost test: </p> <pre class="wiki">#include &lt;boost/test/included/unit_test.hpp&gt; </pre><p> It is easy to make such a mistake and really hard to figure out the reason. I'm posting to raise awareness. </p> </description> <category>Ticket</category> </item> </channel> </rss>