#35369 [NEW]: Serialized objects referencing each other, memory exhaustion when unserializing
| From: | bugreports at insign dot ch | Date: | Thu, 24 Nov 2005 15:15:20 +0000 |
| Subject: | #35369 [NEW]: Serialized objects referencing each other, memory exhaustion when unserializing | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-88852@lists.php.net to get a copy of this message | ||
From: bugreports at insign dot ch
Operating system: Prolly irrelevant (Linux 2.6.4)
PHP version: 5CVS-2005-11-24 (CVS)
PHP Bug Type: Class/Object related
Bug description: Serialized objects referencing each other, memory exhaustion when unserializing
Description:
------------
Objects, referencing each other, are serialized. The reference seems to be
represented as R:1 in the serialized data.
When unserializing the string, it seems (begin of guess) that the
reference is not interpreted correctly and countless objects are
instantiated instead (end of guess) - the script takes remarkably long and
ends with the allowed memory size exhausted.
The problem doesn't seem to occur when the unserialized data is simply
echoed instead of assigned to a variable, but obviously that's not so
useful. The problem still occurs when var_dumping the unserialized data.
The problem exists on PHP 5.1.0RC6, but not on PHP 5.0.5. Unfortunately,
we cannot install the CVS version just for checking if the problem still
exists. We hope you're still willing to at least quickly verify it.
Reproduce code:
---------------
class A {
public $b;
}
class B {
public $a;
}
$a = new A();
$b = new B();
$a->b = &$b;
$b->a = &$a;
$x = unserialize(serialize($a));
Expected result:
----------------
$x is a copy of $a, with $x->b being a copy of $b that holds a reference
to $x. print_r'd that would look like this:
A Object
(
[b] => B Object
(
[a] => A Object
*RECURSION*
)
)
Actual result:
--------------
Memory exhaustion and sometimes a segmentation fault.
--
Edit bug report at http://bugs.php.net/?id=35369&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35369&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35369&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35369&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=35369&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35369&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35369&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35369&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35369&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35369&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35369&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35369&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35369&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35369&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35369&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35369&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35369&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35369&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35369&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35369&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35369&r=mysqlcfg