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

Re: [perl #68192] Tied scalar numeric FETCH corruption after STORE()ing a reference

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
May 16, 2010 17:21
Subject:
Re: [perl #68192] Tied scalar numeric FETCH corruption after STORE()ing a reference
Message ID:
3F808ECC-4AD1-44B4-987C-BA8B8F821289@cpan.org

On Jan 17, 2010, at 2:26 PM, Father Chrysostomos wrote:

>
> On Dec 13, 2009, at 12:58 PM, Father Chrysostomos wrote:
>
>>
>> On Nov 15, 2009, at 1:05 PM, Father Chrysostomos wrote:
>>
>>> This is a regression in perl 5.10.0, caused by http://perl5.git.perl.org/perl.git/commitdiff/800401ee2a8a5a67ef478227b68426cf701d0116 
>>> . The attached patch fixes this. I’m not sure whether what I’ve  
>>> done to sv_2nv is correct. Could someone please review it?
>>
>> Attached is the same patch, updated for 5.11.3.
>
> Updated for 5.11.4.

OK, let’s try this again:

sv_2num doesn’t take get-magic into account, so a tied scalar  
containing a reference is not treated as tied, at least not by numeric  
ops.

In trying to fix this, I found that most ops check for overloading  
before get-magic, which causes the wrong overload methods to be used.  
Fixing this problem fixes the original bug ‘for free’, so I followed  
this approach.

Every pp_ function that does overloading needs to call get-magic up  
front, before checking for overloading. This means they need to call  
the  _nomg variations of the Sv*V macros (to avoid double get-magic).  
Every function that uses SvIV_please needs the same treatment, so I  
modified SvIV_please to be non-magical.

Attached is a new patch, updated for blead (as of May, 2010). This one  
no longer has sv_2nv_flags, since Dave Mitchell added that recently  
when fixing a similar bug in pp_sort.

Attached also is a file (not a patch) with perldelta entries, one of  
which is applicable even without my patch.

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