[Issue 1282] Very strange GC problem, memory corruption

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 21 11:44:57 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1282





------- Comment #5 from sean at f4.ca  2007-06-21 13:44 -------
The GC does know whether an address is in a pool it manages.  For deleting a
typical memory block (ie. not a class), _d_delmemory() is called.  The code for
this is very simple:

    if (*p)
    {
        gc_free(*p);
        *p = null;
    }

So on to gc_free() we go...  the routine is freeNoSync, and this is the first
thing it does:

        pool = gcx.findPool(p);
        if (!pool)
            return;

With this in mind, I don't understand how removing the delete could have solved
your problems, no matter what the spec says.  The only effect should have been
that ps is set to null.  To be sure, I ran your second (short) sample program
through a debugger and confirmed that this is indeed what's happening.  So
perhaps something more specific to your program was causing the actual problem,
and this was merely a contributing factor?  In any case, keep me informed if
the problem resurfaces.


-- 



More information about the Digitalmars-d-bugs mailing list