At 11:21 AM 3/8/2001 -0500, Kort, Eric wrote:
> > -----Original Message-----
> > From: Dan Sugalski [mailto:[EMAIL PROTECTED]]
>
> > You need to get the refcounts correct for the elements of the
> > array. It
> > looks like the else section of the end if statement fetches
> > things out of
> > an array and sticks them in this one without incrementing
> > their refcounts.
> > That might be your problem.
>
>Bingo. If I mortalize, the problem is (almost entirely) resolved:
>
>av_push(avMask, sv_2mortal(*av_fetch(avImage, i*3, 0)) );
Ack! Do *not* do that. Bad, bad, bad! What that'll do is have the scalars
in the array freed the next time temps are cleaned up. If you try and use
them later, Odd Things Will Happen.
Instead, increment the refcounts for the scalars you store that way.
av_fetch does *not* increment the refcounts for the scalars it returns, and
av_push doesn't increment the refcounts of scalars it sticks in the array.
You have two potential leaks here:
1) The array you return isn't properly refcounted and/or mortalized, so it
never goes away
2) The elements of the array may be incorrectly refcounted, and when perl
goes to clean up get their refcounts decremented too much, which means the
refcount will wrap to MAX_INT (probably around 4 billion) and also never go
away.
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk