develooper Front page | perl.perl5.porters | Postings from November 2016

Re: A possible new approach to COW - COW_META.

Thread Previous
Father Chrysostomos
November 7, 2016 14:09
Re: A possible new approach to COW - COW_META.
Message ID:

On Nov 7, 2016, at 12:40 AM, demerphq <> wrote:

>> sv.c:sv_setsv_flags:
>> +                : ( len /* XXX PERL_ANY_COW
>> +                           len == 0 means private buffer which
>> +                           for we will assume we cannot cow.
>> +                           see ext/PerlIO-encoding/encoding.xs */
>> s/XXX |for //g;
>> In case you meant ‘for now’, I think this is a permanent state of affairs and should remain that way.  A ‘static’ PV in an SV is a very useful feature.  But it may not be truly static, so we cannot do COW with it, as some XS module might free the buffer while we are still hanging on to it.
> FWIW, that statement doesn't entirely make sense to me. I understand
> what you are getting at, but I dont see why we would have that trouble
> any more with a COW SvPV than we would with a normal SvPV. Is there
> something that I am overlooking?

An XS module may take a string from a non-Perl structure and have SvPVX point at it, with magic attached to the SV to decrement the reference count on the non-Perl structure that owns the string when the SV is freed.  If we start doing COW with such a string, we will end up with SVs pointing to a freed buffer.

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About