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

[perl #19135] string eval turns off readonlyness on lexicals

From:
Alexandr Ciornii via RT
Date:
May 12, 2010 04:28
Subject:
[perl #19135] string eval turns off readonlyness on lexicals
Message ID:
rt-3.6.HEAD-4976-1273663682-1546.19135-14-0@perl.org
Same result on 5.12.0 with ithreads.

On Sat Dec 14 11:15:57 2002, nicholas wrote:

> Without ithreads, a lexical stays readonly when it is referenced
>    inside
> a string eval:
> 
> $ perl5.8.0-32 -MDevel::Peek -wle 'my $k = "!"; Internals::SvREADONLY
$k, 1; Dump $k; eval "print \$k"; Dump $k'
> SV = PV(0x8112460) at 0x8112210
>   REFCNT = 1
>   FLAGS = (PADBUSY,PADMY,POK,READONLY,pPOK)
>   PV = 0x8111120 "!"\0
>   CUR = 1
>   LEN = 2
> !
> SV = PV(0x8112460) at 0x8112210
>   REFCNT = 1
>   FLAGS = (PADBUSY,PADMY,POK,READONLY,pPOK)
>   PV = 0x8111120 "!"\0
>   CUR = 1
>   LEN = 2
> 
> With ithreads it loses its readonlyness:
> 
> perl5.8.0-32-i -MDevel::Peek -wle 'my $k = "!"; Internals::SvREADONLY
$k, 1; Dump $k; eval "print \$k"; Dump $k'
> SV = PV(0x8125c60) at 0x8125a28
>   REFCNT = 1
>   FLAGS = (PADBUSY,PADMY,POK,READONLY,pPOK)
>   PV = 0x8137120 "!"\0
>   CUR = 1
>   LEN = 2
> !
> SV = PV(0x8125c60) at 0x8125a28
>   REFCNT = 1
>   FLAGS = (PADBUSY,PADMY,POK,pPOK)
>   PV = 0x8137120 "!"\0
>   CUR = 1
>   LEN = 2
> 
> 
> This is still true in blead. It seems wrong. (It's also the source of
> a copy on write bug in blead)
>
> 
> I think it's the code at the line /* could be a freed constant */ in
> Perl_pad_free (formerly of op.c, now in pad.c) that's responsible for
>    this.

-- 
Alexandr Ciornii, http://chorny.net




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