Boost logo

Boost :

Subject: [boost] [Test] Memory leak with boost v1.40 under gcc 4.2 for x86_64 in Snow Leopard
From: S Roderick (kiwi.2008_at_[hidden])
Date: 2009-09-10 13:46:56


[First time poster to boost]

Compiling for the default x86_64 produces a memory leak in the test
framework, but the same program compiled for i386 does not. Mac OS X
Snow Leopard gcc 4.2 with macports boost 1.40.0 (same memory leak seen
in v1.39 macports also). The memory leak only occurs with multiple
test cases or test suites. Set the define in my test program to remove
the extra test case, and the leak dissappears.

Could not find this problem on the list, nor the 'net.

Output is:
<code>
sroderick_at_mp tmp $ g++ -o boost-test-i386 -arch i386 /opt/code/tmp/
boost-test.cpp -I/opt/local/include -g
sroderick_at_mp tmp $ g++ -o boost-test -arch x86_64 /opt/code/tmp/boost-
test.cpp -I/opt/local/include -g
sroderick_at_mp tmp $ ./boost-test
Running 2 test cases...

*** No errors detected
boost-test(75819) malloc: *** error for object 0x3000100300780:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap

sroderick_at_mp tmp $ ./boost-test-i386
Running 2 test cases...

*** No errors detected
</code>

gdb backtrace for x86_64 program is:
<code>
(gdb) bt
#0 0x00007fff83180096 in __kill ()
#1 0x00007fff832210c2 in abort ()
#2 0x00007fff83138215 in free ()
#3 0x000000010006979e in boost::unit_test::framework_impl::clear
(this=0x1000d99c0) at framework.ipp:133
#4 0x000000010006989c in
boost::unit_test::framework_impl::~framework_impl (this=0x1000d99c0)
at framework.ipp:122
#5 0x000000010006ae0e in __tcf_1 () at framework.ipp:225
#6 0x00007fff831443f4 in __cxa_finalize ()
#7 0x00007fff8314430c in exit ()
#8 0x0000000100009703 in start () at unit_test_parameters.ipp:172
</code>

Program is:
<code>
#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_SUITE( test_suite )

BOOST_AUTO_TEST_CASE( test_case1 )
{
// BOOST_ERROR( "some error 1" );
  BOOST_CHECK( true );
}

BOOST_AUTO_TEST_SUITE_END()

#if 1
BOOST_AUTO_TEST_CASE( test_case_on_file_scope )
{
  BOOST_CHECK( true );
}
#endif
</code>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk