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
Father Chrysostomos
May 16, 2010 17:21
Re: [perl #68192] Tied scalar numeric FETCH corruption after STORE()ing a reference
Message ID:

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 
>>> . 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  

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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About