Torsten Foertsch wrote: > On Thursday 11 October 2007 15:18, Torsten Foertsch wrote: >> I am wondering whether the REFCNT is always right. *pnotes is a HV. If the >> function is called without a key argument the else branch newRV_inc >> increments the REFCNT of the HV, right? Then the return statement in the >> last line increments it again? Am I wrong?
Yup, your typical reference counting bug...
> Here is a test that shows what I mean. Under 2.0.3 I get this:
>
> Failed Test Stat Wstat Total Fail List of Failed
> -------------------------------------------------------------------------------
> t/modperl/pnotes2.t 12 8 2 4-6 8 10-12
>
> The test saves an object in pnotes that on DESTROY prints a message to the
> error_log. Further a CleanupHandler is installed to check if the pnotes are
> destroyed after that phase.
>
> In each failing test pnotes are accessed at least once without arguments. The
> stored object is not destroyed because the REFCNT of the HV is too big.
Fixed in rev 584380!
> ->pnotes($key=>$value) works but has other drawbacks. (my $x=1;
> $r->pnotes(x=>$x); undef $x; # undefs also $r->pnotes->{x})
Yes, and I can't find it in the archives right now, but that was a feature
of sorts. mod_perl-1.x used to do it like that, and it was decided to
continue doing the same thing. Not so obvious to the casual user, but
I believe it's even documented somewhere.
------------------------------------------------------------------------
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/
signature.asc
Description: OpenPGP digital signature
