On May 11, 11:28pm, Joshua N Pritikin wrote:
> On Sat, May 11, 2002 at 07:30:24PM -0400, Bradley Brahms wrote:
> > as I have mentioned before I have tried the script with various
> > combinations of perl/malloc on Solaris 7. I have now tried the same script
> > on Linux with the following configurations:
> > Linux 2.2.13-4 gcc 2.91.66 Event.pm 0.85
> > perl 5.005_03 and perl 5.6.1
> >
> > The growth happens in both versions of perl.
>
> That means that Event probably has a reference counting bug.
Sigh... yes. I am wondering myself about a couple things in ev.c:
A. pe_event_invoke. Callbacks only return values via calling
"unloop('value')", not returning something, right? Thus the
G_VOID? Then why not also G_DISCARD?
B. pe_event_release decreases the refcount for ev->mysv; the same
happens in event_2sv thanks to the "sv_2mortal", which
compensates for the SvREFCNT_inc. But ev->mysv is a
reference. What decreases the refcount to the thing it's
referring to? That sv gets created _again_ anytime ev->mysv is 0,
which it will be if the event has gone through pe_event_release
(whether or not ev->mysv is freed...).
SV *event_2sv(pe_event *ev) { /**MAKE FAST**/
if (!ev->mysv) {
SV *rv = newSV(0);
SV *sv = newSVrv(rv,0);
sv_bless(rv, ev->vtbl->stash);
sv_setiv(sv, (IV)ev);
ev->mysv = rv;
if (WaDEBUGx(ev->up) >= 4) {
STRLEN n_a;
warn("Event=0x%x '%s' wrapped with SV=0x%x",
ev, SvPV(ev->up->desc, n_a), SvRV(ev->mysv));
}
}
return SvREFCNT_inc(sv_2mortal(ev->mysv));
}
The above may be complete nonsense; I am _not_ very good at C. But even if
it has nothing to do with this memory leak, I'm still curious...
-Allen
--
Allen Smith http://cesario.rutgers.edu/easmith/
September 11, 2001 A Day That Shall Live In Infamy II
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety." - Benjamin Franklin