perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject Re: possible pnotes refcounting bug ?
Date Fri, 12 Oct 2007 11:18:28 GMT
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?

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.

->pnotes($key=>$value) works but has other drawbacks. (my $x=1; 
$r->pnotes(x=>$x); undef $x; # undefs also $r->pnotes->{x})

Torsten

Mime
View raw message