From: frode at coretrek dot com Operating system: Linux PHP version: 5CVS-2006-07-14 (snap) PHP Bug Type: Scripting Engine problem Bug description: print_r tries to allocate 1.5gb RAM and fails, corrupt array/hash?
Description: ------------ Assigning an array to an object field and updating it through use of __get/__set() no longer works in PHP 5.2 snapshots. This is probably related to the fix for bug 37667. Below is a test case based on the one in bug 37667, which is similar to a larger real code base we have working in PHP 5.1.4. This test case does not trigger bug 37667 because we create the array through __set() - bug 37667 does not set the new array this way. "Expected result" shows output in PHP 5.1.4 "Actual result" shows output in PHP5.2-200607140630 Running on apache 2.2.2. Reproduce code: --------------- <? header("Content-type: text/plain"); class Class1 { protected $property = array(); function __get($name) { return $this->property; } function __set($name, $val) { $this->$name = $val; } } class Class2 {} $r = new Class1(); $r->property = array(); $r->property["what"] = new Class2(); $r->property["who"] = new Class2(); var_dump($r); ?> Expected result: ---------------- object(Class1)#1 (1) { ["property:protected"]=> array(2) { ["what"]=> object(Class2)#2 (0) { } ["who"]=> object(Class2)#3 (0) { } } } Actual result: -------------- <br /> <b>Fatal error</b>: Cannot use array returned from Class1::__get('property') in write context in <b>/devel2/frode/www/_/test37667.php</b> on line <b>16</b><br /> -- Edit bug report at http://bugs.php.net/?id=38102&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38102&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38102&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38102&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38102&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38102&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38102&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38102&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38102&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38102&r=support Expected behavior: http://bugs.php.net/fix.php?id=38102&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38102&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38102&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38102&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38102&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38102&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38102&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38102&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38102&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38102&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38102&r=mysqlcfg