|
Boost Users : |
Subject: Re: [Boost-users] [Boost.Test] valgrind complains about invalid reads
From: Peter Klotz (peter.klotz_at_[hidden])
Date: 2008-11-22 15:08:25
Gennadiy Rozental wrote:
> Peter Klotz <peter.klotz <at> aon.at> writes:
>
>> Why not just adding the virtual destructor to make valgrind happy?
>
> Did you try removing virtual from test_suite destructor instead?
>
Yes, just making ~test_suite() non virtual worsens things.
valgrind complains about twice as many "invalid read" errors.
Here my results:
Boost 1.37.0 unpatched (~test_suite() is virtual, ~test_unit() is not):
==22485== Invalid read of size 4
...
==22485== by 0x806BB09:
boost::unit_test::framework::deregister_test_unit(boost::unit_test::test_unit*)
(framework.ipp:326)
==22485== by 0x80602EA: boost::unit_test::test_unit::~test_unit()
(unit_test_suite.ipp:65)
==22485== by 0x806F06C: boost::unit_test::test_case::~test_case()
(unit_test_suite_impl.hpp:110)
Boost 1.37.0 patched (~test_suite() and ~test_unit() are non virtual):
==22946== Invalid read of size 4
...
==22946== by 0x806B9E5:
boost::unit_test::framework::deregister_test_unit(boost::unit_test::test_unit*)
(framework.ipp:326)
==22946== by 0x80602E2: boost::unit_test::test_unit::~test_unit()
(unit_test_suite.ipp:65)
==22946== by 0x806F236: boost::unit_test::test_case::~test_case()
(unit_test_suite_impl.hpp:110)
==22946== Invalid read of size 4
...
==22946== by 0x806B9E5:
boost::unit_test::framework::deregister_test_unit(boost::unit_test::test_unit*)
(framework.ipp:326)
==22946== by 0x80602E2: boost::unit_test::test_unit::~test_unit()
(unit_test_suite.ipp:65)
==22946== by 0x806F214: boost::unit_test::test_suite::~test_suite()
(unit_test_suite_impl.hpp:141)
==22946== by 0x806F2A7: boost::unit_test::framework_impl::clear()
(framework.ipp:131)
Making ~test_unit() virtual removes all errors. Then even a non virtual
~test_suite() is no longer a problem.
So the final conclusion would be to remove virtual from ~test_suite()
and add it to the base class destructor ~test_unit().
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