develooper Front page | perl.perl5.porters | Postings from May 2015

Re: FYI - PM posted about a horrible List::Util::first bug

Thread Previous
From:
Dave Mitchell
Date:
May 27, 2015 10:54
Subject:
Re: FYI - PM posted about a horrible List::Util::first bug
Message ID:
20150527105403.GO15483@iabyn.com
On Wed, May 27, 2015 at 10:57:25AM +0100, Dave Mitchell wrote:
> The arg passed to lc in the first() code block above is
> 
>     SV = PV(0xa8ac28) at 0xaaa2d0
>       REFCNT = 1
>       FLAGS = (TEMP,POK,IsCOW,pPOK)
>       PV = 0xaa3c78 "ZXC"
>       CUR = 3
>       LEN = 0
> 
> which satisfies the 'in-place' test of
> 
>     if (   (  SvPADTMP(source)
> 	   || (  SvTEMP(source) && !SvSMAGICAL(source)
> 	      && SvREFCNT(source) == 1  )
> 	   )
> 	&& !SvREADONLY(source) && SvPOK(source)
> 	&& !DO_UTF8(source)) {
> 
> So I don' think that condition is strong enough, and I'm not sure that
> that there is such a safe condition.

NB the difference between List::Util's first() and perl's grep is
that with grep, $_ has a refcount of 2. grep also makes mortal copies of
any PADTMP args and/or turns off the TEMP flag.

So perhaps it's List::Util that needs to perform similar safeguards,
rather than lc() etc being at fault???

-- 
The Enterprise is captured by a vastly superior alien intelligence which
does not put them on trial.
    -- Things That Never Happen in "Star Trek" #10

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