Boost logo

Boost Users :

Subject: [Boost-users] [Boost.Test] Error: Non-aligned pointer being freed
From: Sebastian Hauer (sebastian.hauer_at_[hidden])
Date: 2009-07-04 11:52:32


Hello Boost Users,
when running my unit tests on Mac OS X compiled with darwin gcc 4.2.1
for x86_64 I am getting the following error messages printed out even
though no testing error were detected. As a side note running the same
unit test on Windows MSVC 8 or Solaris gcc 3.2 succeeds without
issues, so this seems to be either gcc 4.2 or Mac OS X specific.

---------------
hauer_at_gandalf:~/dev/shark4/utils$
bin/darwin-4.2.1/debug/address-model-64/architecture-x86/shark-utilstest_d
Running 51 test cases...

*** No errors detected

shark-utilstest_d(45498) malloc: *** error for object 0x3000100301fb0:
Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
shark-utilstest_d(45498) malloc: *** error for object 0x30001003020c0:
Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
shark-utilstest_d(45498) malloc: *** error for object 0x3000100302200:
non-page-aligned, non-allocated pointer being freed
*** set a breakpoint in malloc_error_break to debug
---------------

I then ran the test through gdb and set a breakpoint at
malloc_error_break and took a backtrace as shown below:

----------------
Starting program:
/Users/hauer/dev/shark/utils/bin/darwin-4.2.1/debug/address-model-64/architecture-x86/shark-utilstest_d
warning: posix_spawn failed, trying execvp, error: 86
Reading symbols for shared libraries ++++++.. done
Breakpoint 1 at 0x7fff83745a51
Running 51 test cases...

*** No errors detected
pirate-utilstest_d(45520) malloc: *** error for object
0x3000100300630: Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug

Breakpoint 1, 0x00007fff83745a51 in malloc_error_break ()
(gdb) bt
#0 0x00007fff83745a51 in malloc_error_break ()
#1 0x00007fff83740ad0 in szone_error ()
#2 0x00000001001655f8 in boost::unit_test::framework_impl::clear
(this=0x1001c7600) at impl/framework.ipp:133
#3 0x0000000100165728 in
boost::unit_test::framework_impl::~framework_impl (this=0x1001c7600)
at impl/framework.ipp:122
#4 0x0000000100160d82 in __tcf_1 () at impl/framework.ipp:222
#5 0x00007fff8369d3dc in __cxa_finalize ()
#6 0x00007fff8369d2f2 in exit ()
#7 0x0000000100000ceb in start ()
------------------

This point to framework_impl's clean() method:

------------------
    void clear()
    {
        while( !m_test_units.empty() ) {
            test_unit_store::value_type const& tu =
*m_test_units.begin();

            // the delete will erase this element from map
            if( test_id_2_unit_type( tu.second->p_id ) == tut_suite )
                delete (test_suite const*)tu.second;
            else
                delete (test_case const*)tu.second; // <-- Line 133
        }
    }
-----------------

I think test_case's dtor was made public in 1.39 but I guess this did
not fix the problem at hand.

Regards,
Sebastian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net