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

Re: Threads in CHECK/INIT blocks leak scalars

Thread Previous
Dave Mitchell
March 26, 2007 16:28
Re: Threads in CHECK/INIT blocks leak scalars
Message ID:
On Fri, Mar 16, 2007 at 08:22:59AM -0700, Jerry D. Hedden wrote:
> Using threads inside CHECK or INIT blocks causes leaked scalars:
> > perl -Mthreads -e 'CHECK { threads->create(sub {})->join; }'
> Scalars leaked: 1
> What is the scalar that is leaking?

It's the cloned copy of the CHECK CV. It's cloned because the anon sub has
a weak reference to it, but has a refcnt of zero due to that weak
reference. It also exists on the savestack (having just been shifted off
PL_checkav in Perl_call_list), but that's not cloned.

> Can this be fixed?

Dunno. There was another problem with items only on the savestack leaking,
and Nicholas suggested a fix that I need to get me head round one day.

The optimist believes that he lives in the best of all possible worlds.
As does the pessimist.

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About