From:             yaauie
Operating system: ALL
PHP version:      5.4SVN-2011-07-27 (SVN)
Package:          *General Issues
Bug Type:         Bug
Bug description:ref lost: 1st ref instantiated in class def, 2nd ref made w/o 
instantiating

Description:
------------
Reference is lost, causing segfault and/or oddities when primary reference
is 
edited after secondary is edited.

Occurs only when the variable name is instantiated in the class definition,
and 
the second reference is not instantiated before it is made. Possible
workarounds 
include:

Instantiate neither variable name in the class definition
Instantiate both variable names in the class definition
Instantiate secondary variable name before making it a reference to the
first:
  $this->bar = nil;
  $this->bar =& $this->foo;

The bug is new to 5.4.

Test script:
---------------
<?php
class Foo {
  var $foo; # bug present
  function __construct(){
    $this->foo = '';
    $this->bar =& $this->foo;
  }
  function dump(){
    echo 'foo: ';var_dump($this->foo);
    echo 'bar: ';var_dump($this->bar);
  }
}

$f = new Foo();
$f->dump();
$f->foo .= 'foo';
$f->dump();
$f->bar .= 'bar';
$f->dump();
$f->foo .= 'foo';
$f->dump();
?>

Expected result:
----------------
foo: string(0) ""
bar: string(0) ""
foo: string(3) "bar"
bar: string(3) "bar"
foo: string(6) "barfoo"
bar: string(6) "barfoo"


Actual result:
--------------
varies from platform to platform

On Windows:

foo: string(0) ""
bar: NULL
foo: string(3) "foo"
bar: NULL
foo: UNKNOWN:0
bar: string(3) "bar"
CRASH

On Linux (Ubuntu 11.04):

foo: string(0) ""
bar: NULL
foo: NULL
bar: string(3) "bar" 
foo: string(3) "foo"
bar: string(3) "???"

where ?? is 3 seemingly-random bytes.

OR, if an additional one-or-three-parameter method is defined in the class
(even 
if it is not called):

string(0) ""
NULL
NULL
Segmentation fault

If the uncalled method has a different number of arguments, it generates a

zend_mm_heap_corrupted instead

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55305&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55305&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55305&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55305&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55305&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55305&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55305&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55305&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55305&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55305&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55305&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55305&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55305&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55305&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55305&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55305&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55305&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55305&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55305&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55305&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55305&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55305&r=mysqlcfg

Reply via email to