#43319 [Com]: Serialization of objects with Serializable interface and circular references
| From: | crrodriguez+php at suse dot de | Date: | Sun, 18 Nov 2007 04:28:44 +0000 |
| Subject: | #43319 [Com]: Serialization of objects with Serializable interface and circular references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119776@lists.php.net to get a copy of this message | ||
ID: 43319
Comment by: crrodriguez+php at suse dot de
Reported By: dnfeitosa@php.net
Status: Open
Bug Type: Reproducible crash
Operating System: Linux, Windows
PHP Version: 5.2.5
New Comment:
This causes infinite recursion,hence a crash.. I expect a very clear:
zend_error(E_ERROR, "Nesting level too deep - recursive dependency?");
Previous Comments:
------------------------------------------------------------------------
[2007-11-17 15:26:04] dnfeitosa@php.net
Description:
------------
Apache crashes and CLI segfault when serializing objects which have
circular references and implements the Serializable interface.
Whitout the interface, the serialization and deserialization occurs
without any problem.
Reproduce code:
---------------
<?php
class A implements Serializable {
private $b;
public function setB($b) {
$this->b = $b;
}
public function serialize() {
return serialize($this->b);
}
public function unserialize($s) {
$this->b = unserialize($s);
}
}
class B {
private $a;
public function __construct($a) {
$a->setB($this);
$this->a = $a;
}
}
$a = new A();
$b = new B($a);
var_dump(serialize($b));
?>
Expected result:
----------------
The string of the serialized object.
Actual result:
--------------
Apache crash or cli segfault.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43319&edit=1