Boost logo

Boost :

Subject: Re: [boost] [test] console_test_runner ported on *nix
From: Gennaidy Rozental (rogeeff_at_[hidden])
Date: 2008-09-19 15:02:46


Kevin Sopp <baraclese <at> googlemail.com> writes:

>
> What happens is that delete (test_case const*) tu.second; first
> invokes the test_case destructor which will erase the value referenced
> by tu from the map, then the delete statement continues but tu
> references deallocated memory now at which point valgrind complains
> that you do an invalid read of 4 bytes.

>From what I understand order of events is as follows:

1. tu.second resolved (memory accessed)
2. ~test_case() invoked
3. ~test_unit() invoked
4. framework::deregister_test_unit( this ) is invoked
5. map.erase( tu )
6. free( ptr )

If what you saying is true we perform first step twice. Second time before 6th
step. Why would compiler do this?

Can you test it? just create temp pointer test_unit* tu_ptr = tu.second; before
delete.

Gennadiy


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