I was debugging a strange problem where an object VMT suddenly points to the base object's methods.
class base {virtual zero foo () {}} class derived: public base {void foo () {}} derived derived * d = new; ... very complex fettling ... d-foo (); // help! Base: foo () is called !!! This was a bug effectively in the 'complex' code deleted; I will not go into details except to tell that boost :: noncopyable is your friend, and never under any circumstances does not ever roll their smart pointers classes. But my question is - does this kind of change of VMT have a good 'smell' that you are working with a deleted object? I think VMT 'gets' unrolled' on ' base during destruction'? Obviously this is very dependent on implantation, and I was 'lucky' that the memory was not crushed on ...
Definitely what the question is ??? But IA says that this:
I was 'lucky' that the memory was not crushed ...
is wrong: you lucky is ???? You were lucky united were removed during the time of memory being crushed, then you probably would have a code accident near the real problem and the error would be very clear. The code fails as soon as possible, promptly about the failure location as soon as possible.
Comments
Post a Comment