#43319 [Opn->Bgs]: Serialization of objects with Serializable interface and circular references
| From: | johannes@php.net | Date: | Sun, 18 Nov 2007 19:03:17 +0000 |
| Subject: | #43319 [Opn->Bgs]: Serialization of objects with Serializable interface and circular references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119792@lists.php.net to get a copy of this message | ||
ID: 43319
Updated by: johannes@php.net
Reported By: dnfeitosa@php.net
-Status: Open
+Status: Bogus
Bug Type: Reproducible crash
Operating System: Linux, Windows
PHP Version: 5.2.5
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
When having your own serialization function you have to take care of
recursion yourself. We can't handle infinite recursions in a good way,
see other bug reports about recursion issues.
Previous Comments:
------------------------------------------------------------------------
[2007-11-18 17:35:41] dnfeitosa@php.net
I don't know if this is the more apropriated solution for this
problem.
When you try without the use of interface, you have the same recursion,
but no crash.
------------------------------------------------------------------------
[2007-11-18 04:28:43] crrodriguez+php at suse dot de
This causes infinite recursion,hence a crash.. I expect a very clear:
zend_error(E_ERROR, "Nesting level too deep - recursive dependency?");
------------------------------------------------------------------------
[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