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

Re: A possible new approach to COW - COW_META.

Thread Previous
From:
Father Chrysostomos
Date:
November 7, 2016 14:09
Subject:
Re: A possible new approach to COW - COW_META.
Message ID:
FAD54E5F-2DB4-405C-A009-D31773BCBDE7@cpan.org

On Nov 7, 2016, at 12:40 AM, demerphq <demerphq@gmail.com> 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


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