On Thu May 09 09:07:02 2013, davem wrote: > Note that there is no guarantee that the return value of C<SvPV()> is > -equal to C<SvPVX(sv)> (or even that C<SvPVX(sv)> contains valid > data), due > -to the way that things like overloading and Copy-On-Write are > handled. In > -these cases, the return value may point to a temporary buffer or > similar. > -If you absolutely need the SvPVX field to be valid (for example, if > you > -intend to write to it), then see L</SvPV_force>. > +equal to C<SvPVX(sv)>, or that C<SvPVX(sv)> contains valid data, or > that > +successive calls to C<SvPV(sv)) will return the same pointer value > each > +time. This is due to the way that things like overloading and > +Copy-On-Write are handled. In these cases, the return value may > point to > +a temporary buffer or similar. If you absolutely need the SvPVX > field to > +be valid (for example, if you intend to write to it), then see > +L</SvPV_force>. > > "(for example, if you intend to write to it), then see L</SvPV_force>." SvPV_force runs get magic, so if you are "writing to SvPVX", you just at minimum did "read" and then maybe (if you are doing XS right) "write" for what should have been just a "write", which is wrong in magic land. Also SvPV_force might have done a "sv_2pv_flags" internally to generate a valid PV buffer (IV to PV conversion) which will be immediately overwritten (and wasted cpu to generate it) by passing SvPVX to a non-perl C function. The previous sentence might need to be another ticket. perlguts in blead says nothing about SvPV is not SvPVX and says nothing about COW. -- bulk88 ~ bulk88 at hotmail.com --- via perlbug: queue: perl5 status: resolved https://rt.perl.org:443/rt3/Ticket/Display.html?id=116407Thread Previous | Thread Next