From:             robin_fernandes at uk dot ibm dot com
Operating system: Windows
PHP version:      5CVS-2007-10-15 (snap)
PHP Bug Type:     Reproducible crash
Bug description:  ReflectionClass::newInstance[Args]() crashes if ctor takes 
arg by reference

Description:
------------
In some cases, ReflectionClass::newInstance() and
ReflectionClass::newInstanceArgs() can trigger a segmentation fault when
the constructor of the reflected class takes arguments by reference.

Tested on PHP 5.2.5-dev (cli) (built: Oct 15 2007 12:04:27) on Win XP.

Reproduce code:
---------------
<?php
Class C {
        function __construct(&$x) {
                $x = "x.changed";
        }
}

$x = "x.original";
new C($x); // OK
var_dump($x);

$rc = new ReflectionClass('C');
$x = "x.original";
$rc->newInstance($x); // causes crash
var_dump($x);
$x = "x.original";
$rc->newInstanceArgs(array($x)); // causes crash        
var_dump($x);
?>

Expected result:
----------------
string(9) "x.changed"
string(9) "x.changed"
string(10) "x.original"

Actual result:
--------------
string(9) "x.changed"
*CRASH*

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

Reply via email to