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

Re: Threads in CHECK/INIT blocks leak scalars

Thread Previous
From:
Dave Mitchell
Date:
March 26, 2007 16:28
Subject:
Re: Threads in CHECK/INIT blocks leak scalars
Message ID:
20070326232936.GI5473@iabyn.com
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


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