PMC_EXT error

Whiteknight on 2008-08-08T00:50:55

A while back I added PMC_EXTs, those little data doodads that add extra pointers to a PMC, to the GC system. There were a few problems where PMC_EXTs weren't being properly freed when their parent PMC was being freed, and that created a memory leak, among other problems.

So, to fix the issue, I added PMC_EXT to the GC system. Now, they're completely managed and we don't need to worry about manually freeing them. However, this created a new problem. Here's a line that shows how the sized pools are stored and accessed:

interp->arena_base->sized_header_pools[(object_size - sizeof (Buffer)) / sizeof (void*)];

Now, what is this result:

(sizeof (PMC_EXT) - sizeof (Buffer)) / sizeof (void*) = ?

In this case, the answer is -1, a dangerous value to be using as an array index in unmanaged C. I'm working to fix this now, and hopefully that will help with some of my problems.