Regression?

Sebastian Sauer mail at dipe.org
Thu Feb 7 03:11:04 CET 2008


On Thursday 07 February 2008, Chani wrote:
> On February 7, 2008 09:38:07 Sebastian Sauer wrote:
> > On Thursday 07 February 2008, Chani wrote:
> > > > +    //lay = 0;
> > >
> > > *that* would have caused a crash if anyone was using the mediacenter
> > > formfactor yet. :) silly layouts.
> >
> > y, double free's are wired cause they may crash but may also just work
> > well. Well, maybe there is a switch for gcc to do it like msvc in
> > debug-mode and just always crash/assert, no idea there.
>
> why? because you didn't set lay to 0, but you did call setLayout(0) which
> deletes it, and then lower down in the code there's a block that does stuff
> with lay.


shorter sample of what was happen there;

class A
{
};

class B
{
    public:
        A* a;
};

int main(int argc, char **argv)
{
    /* setup the instances */
    B* b = new B();
    b->a = new A();
    A* a2 = b->a;

    /* do what setLayout(0) was doing */
    delete b->a;
    b->a = 0;

    /* following may crash since a2!=0 but still contains a pointer to 
something that got delete already above. But in the worst case it may also 
just not crash but just corrupts some memory and then you will earn very 
dirty and hard to catch crashes and other maybe even not related places. */
    delete a2; 
}



More information about the Panel-devel mailing list