Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.Test] Error: Non-aligned pointer being freed
From: Peter Klotz (peter.klotz_at_[hidden])
Date: 2009-07-04 13:44:57


Hello Sebastian

Sebastian Hauer wrote:
> 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.
> 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.

The problem you are seeing is exactly the same I reported a while ago
against Boost 1.37.0 (and it is still present in 1.39.0).

Please have a look at this thread:

http://www.nabble.com/-Boost.Test--valgrind-complains-about-invalid-reads-td20500154.html

I finally proposed to rewrite framework_impl::clear() and to make the
test_unit destructor virtual. This solves the valgrind issue in my test
program.

The original code tries hard to not destroy a derived class (test_suite,
test_case) through a base class (test_unit) pointer in
framework_impl::clear(). Doing so would require a virtual test_unit
destructor.

Regards, Peter.


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