ID: 45826
User updated by: kevin dot armenat at googlemail dot com
Reported By: kevin dot armenat at googlemail dot com
Status: Open
Bug Type: Reproducible crash
Operating System: Ubuntu Linux 8.04
PHP Version: 5.3.0alpha1
New Comment:
You still need this short code to reproduce the error, its related to
the ArrayObject, not to the User defined Classes.
$x = new ArrayObject();
$x->append($x);
serialize($x);
Previous Comments:
------------------------------------------------------------------------
[2008-08-15 00:14:14] kevin dot armenat at googlemail dot com
Description:
------------
Serialize causes a segmentation fault if you try to serialize an object
("A") which contains an object ("B") which references to object "A".
Its still working with PHP 5.2.4, but it crashes with PHP 5.3.0alpha1.
Reproduce code:
---------------
class A {
private $bList;
public function __construct() {
$this->bList = new ArrayObject();
}
public function addB(B $b) {
$this->bList->append($b);
}
}
class B {
private $parentA;
public function __construct(A $parentA) {
$this->parentA = $parentA;
}
}
$a = new A();
$b = new B($a);
$a->addB($b);
echo serialize($a);
Expected result:
----------------
The serialized Object of the class "A"
Actual result:
--------------
#0 0xb744b8a8 in _zend_mm_alloc_int (heap=0x81e0db8, size=20) at
/home/kevin/php-5.3.0alpha1/Zend/zend_alloc.c:1743
#1 0xb745c821 in zend_call_function (fci=0xbf15f148,
fci_cache=0xbf15f16c) at
/home/kevin/php-5.3.0alpha1/Zend/zend_execute_API.c:894
#2 0xb747b018 in zend_call_method (object_pp=0xbf15f200,
obj_ce=0x824bfc8, fn_proxy=0x824c0dc, function_name=0xb77311f0
"serialize",
function_name_len=9, retval_ptr_ptr=0xbf15f1ec, param_count=0,
arg1=0x0, arg2=0x0)
at /home/kevin/php-5.3.0alpha1/Zend/zend_interfaces.c:89
#3 0xb747b26d in zend_user_serialize (object=0x82f1164,
buffer=0xbf15f28c, buf_len=0xbf15f278, data=0xbf15f570)
at /home/kevin/php-5.3.0alpha1/Zend/zend_interfaces.c:414
#4 0xb73dc722 in php_var_serialize_intern (buf=0xbf15f5a8,
struc=0x82f1164, var_hash=0xbf15f570)
at /home/kevin/php-5.3.0alpha1/ext/standard/var.c:694
#5 0xb73dc497 in php_var_serialize_intern (buf=0xbf15f5a8,
struc=0x82f0f88, var_hash=0xbf15f570)
at /home/kevin/php-5.3.0alpha1/ext/standard/var.c:795
#6 0xb73dc497 in php_var_serialize_intern (buf=0xbf15f5a8,
struc=0x82f1300, var_hash=0xbf15f570)
at /home/kevin/php-5.3.0alpha1/ext/standard/var.c:795
#7 0xb73dc497 in php_var_serialize_intern (buf=0xbf15f5a8,
struc=0x82f128c, var_hash=0xbf15f570)
at /home/kevin/php-5.3.0alpha1/ext/standard/var.c:795
#8 0xb73de049 in php_var_serialize (buf=0xbf15f5a8, struc=0x82f11e4,
var_hash=0xbf15f570)
at /home/kevin/php-5.3.0alpha1/ext/standard/var.c:814
#9 0xb72f0838 in zim_spl_Array_serialize (ht=0,
return_value=0x8568bbc, return_value_ptr=0xbf15f79c,
this_ptr=0x82f1164,
return_value_used=1) at
/home/kevin/php-5.3.0alpha1/ext/spl/spl_array.c:1491
#10 0xb745c891 in zend_call_function (fci=0xbf15f6f8,
fci_cache=0xbf15f71c) at
/home/kevin/php-5.3.0alpha1/Zend/zend_execute_API.c:898
#11 0xb747b018 in zend_call_method (object_pp=0xbf15f7b0,
obj_ce=0x824bfc8, fn_proxy=0x824c0dc, function_name=0xb77311f0
"serialize",
function_name_len=9, retval_ptr_ptr=0xbf15f79c, param_count=0,
arg1=0x0, arg2=0x0)
at /home/kevin/php-5.3.0alpha1/Zend/zend_interfaces.c:89
[...]
endless repeated
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45826&edit=1