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

Re: [perl #117299] keys are readonly in perl 5.14.2!

Thread Previous | Thread Next
From:
demerphq
Date:
March 22, 2013 16:58
Subject:
Re: [perl #117299] keys are readonly in perl 5.14.2!
Message ID:
CANgJU+WaEoK6j_xEsKC_1fLGaBu6xSnJdAzXnkKigrEXLeHmOA@mail.gmail.com
On 22 March 2013 17:54, Zefram via RT <perlbug-followup@perl.org> wrote:
> yves orton wrote:
>>  FLAGS = (POK,FAKE,READONLY,pPOK)
>
> FAKE+READONLY means it's not actually unwritable, it's copy-on-write.
> From sv.h:
>
> #define SVf_FAKE        0x01000000  /* 0: glob or lexical is just a copy
>                                        1: SV head arena wasn't malloc()ed
>                                        2: in conjunction with SVf_READONLY
>                                           marks a shared hash key scalar
>                                           (SvLEN == 0) or a copy on write
>                                           string (SvLEN != 0) [SvIsCOW(sv)]
>
> In your case, SvLEN == 0, marking it as a shared hash key.
>
> $ perl5.14.2 -MDevel::Peek -le'print $]; my %hash=("A".."D"); @x= keys %hash; Dump($x[0]); $x[0] = "foo"; Dump($x[0])'
> 5.014002
> SV = PV(0x83d2100) at 0x83e2cc0
>   REFCNT = 1
>   FLAGS = (POK,FAKE,READONLY,pPOK)
>   PV = 0x83ed36c "A"
>   CUR = 1
>   LEN = 0
> SV = PV(0x83d2100) at 0x83e2cc0
>   REFCNT = 1
>   FLAGS = (POK,pPOK)
>   PV = 0x83d8330 "foo"\0
>   CUR = 3
>   LEN = 12

Ah. I see. So the bug is in HTML::Entities.

The actual code that kicked this off was this:

$ booking-perl5.14.2 -MDevel::Peek -MHTML::Entities -le'print $]; my
%hash=("A".."D"); @x= sort keys %hash; decode_entities($x[0]);'
5.014002
Can't inline decode readonly string at -e line 1.

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


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