develooper Front page | perl.perl5.porters | Postings from July 2009

Re: [perl #60472] Module Encode degrades in Perl 5.10

Thread Previous | Thread Next
From:
Tony Cook
Date:
July 8, 2009 05:08
Subject:
Re: [perl #60472] Module Encode degrades in Perl 5.10
Message ID:
20090708120749.GA3978@mars.tony.develop-help.com
On Mon, Jul 06, 2009 at 07:54:42AM -0700, Tony Cook via RT wrote:
> With $1 not READONLY this calls SvPV_force() which sets POK, upgrade PVX
> (if needed), and then set UTF8.  This doesn't call mg_set(), so the
> read-only handling in Perl_reg_numbered_buff_store isn't triggered to
> produce a read only value error.

I've confirmed SvPV_force() will set POK if called on $1 [1].

Since SvPV() simply returns PVX when POK is set, any magic is ignored
on later use of $1.

So the main questions here is whether SvPV_force() should set SVf_POK
on an SV with get magic?

I suspect SvPV_force() shouldn't be setting POK, but I don't know what
the policy is.

> I'm not sure what the desired behaviour would be between
> sv_utf8_upgrade(), SvPV_force() and set magic.  This makes me wonder if
> $1 should be just marked READONLY.

I'm sure it shouldn't be.

-- 
[1] By calling an XS function defined:

void
SvPV_force(sv)
	SV * sv
  PREINIT:
	STRLEN len;
  PPCODE:
	SvPV_force(sv, len);

$ perl -Mblib -MT60472 -MDevel::Peek -le '$_ = "abcd"; /..(.)/; print $1; T60472::SvPV_force($1); Dump($1); /.(.)/; print $1'
c
SV = PVMG(0x13aaed0) at 0x13e4960
  REFCNT = 1
  FLAGS = (GMG,SMG,POK,pPOK)
  IV = 0
  NV = 0
  PV = 0x13894a0 "c"\0
  CUR = 1
  LEN = 8
  MAGIC = 0x13ee9b0
    MG_VIRTUAL = &PL_vtbl_sv
    MG_TYPE = PERL_MAGIC_sv(\0)
    MG_OBJ = 0x13e4900
    MG_LEN = 1
    MG_PTR = 0x13ee8d0 "1"
c

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