From:             truth at proposaltech dot com
Operating system: SuSE w/ rebuilt php & deps
PHP version:      4.4.0
PHP Bug Type:     Scripting Engine problem
Bug description:  Unadvertised BC break

Description:
------------
Based on the discussion on internals that led to the 
creation of php 4.4 (and based on the release notes
for php 4.4), I would expect the only difference in
running the following code under 4.3 and 4.4 to be the
generation of a notice under 4.4.  The code is bad,
but it does not rely on corrupting memory.
(BTW, this actually doesn't affect me personally because 
I immediately cleaned up our company's code for every
4.4 notice.  I'm just helping isolate the BC break
that frustrated a recent internals poster.  Unless
they are relying on memory corruption, users should be
able to hide the notices and get the same behavior
with 4.4 as 4.3.  (There were posts from Zeev among
others supporting this position.))

I hope this is easy to fix.  The concept is easy.
Whenever the code attempts to set a variable by
reference, the variable should be unset as a first
step.  In the example, $y should be disconnected
from $x because of the "$y =& ...".  Yes, the reference
shouldn't actually work, but that doesn't change the
fact that the code clearly indicates that the connection
between $y and $x should be broken.  If I sound
defensive, it's because Derick has already posted on
internals that the new behavior is "correct".  Please
check with other engine gurus before jumping to any
conclusions of bogusness.  I think a fix to this BC
break will save many hours for many, many php 
developers.  (The example is silly, but you
can get subtle cases of that problem in loops that
are a nightmare to find.)

Thanks!
- Todd

Reproduce code:
---------------
<?php
function f() { return 3; }
$x = 5;
$y =& $x;
$y =& f();
var_dump($x);
?>


Expected result:
----------------
$x should end up 5 because the "$y=&..." should disconnect
$y from $x even though the new connection can't be made.

Actual result:
--------------
Under 4.3, $x ends up 5, but under 4.4, $x ends up 3.

-- 
Edit bug report at http://bugs.php.net/?id=34551&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34551&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34551&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34551&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34551&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34551&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34551&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34551&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34551&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34551&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34551&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34551&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34551&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34551&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34551&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34551&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34551&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34551&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34551&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34551&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34551&r=mysqlcfg

Reply via email to