develooper Front page | perl.perl5.porters | Postings from March 2000

panic: magic_killbackrefs

From:
Unknown Sender
Date:
March 6, 2000 23:40
Subject:
panic: magic_killbackrefs
Message ID:
20000307083956.K23830@noris.de
(during global destruction).

I was using weak reference support (whoever implemented this deserves an
award for Most Useful New Feature -- seriously) to implement an object
cache.

My code works along the lines of ...

use WeakRef;
my %cache;
my @cache;

{ ## from 'sub new'
	my $obj = bless {x=>"y"}, "foo";
	$cache{x} = $obj;
	weaken($cache{x});
	push(@cache,$obj); shift @cache if @cache > 10;
}

... though this test case doesn't exhibit the problem.

One workaround is to clear either %cache or @cache (or both) in an END
block, but IMHO that should not be necessary.

-- 
Matthias Urlichs  |  noris network GmbH   |   smurf@noris.de  |  ICQ: 20193661
The quote was selected randomly. Really.    |      http://www.noris.de/~smurf/
-- 
Never put off until tomorrow what you can do today.  There might be a
law against it by that time.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About