Edit report at https://bugs.php.net/bug.php?id=55219&edit=1
ID: 55219
Comment by: errebi at gmail dot com
Reported by: garic dot suess+php at gmail dot com
Summary: Segmentation fault with Serializable Object on
self-reference
Status: Verified
Type: Bug
Package: Reproducible crash
Operating System: Ubuntu Linux 10.10 x64
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
I can reproduce it on PHP 5.2.11, but the result is quite different. (one more
itaration)
object(Test)#1 (2) {
["member"]=>
object(Test)#1 (2) {
["member"]=>
*RECURSION*
["message"]=>
string(8) "original"
}
["message"]=>
string(8) "original"
}
Segmentation fault
Hope could help
Previous Comments:
------------------------------------------------------------------------
[2011-07-17 08:23:58] [email protected]
On 5.4 and trunk works because the r299770 change (Added support for object
references in recursive serialize() calls. FR #36424)
------------------------------------------------------------------------
[2011-07-17 07:48:36] [email protected]
I can reproduce it only in 5.3 branch. It's due a stack call overflow.
------------------------------------------------------------------------
[2011-07-16 23:46:29] garic dot suess+php at gmail dot com
Description:
------------
---
>From manual page: http://www.php.net/class.serializable
---
When a Serializable object contains a reference to it self a Segmentation fault
is caused.
I first encountered this in 5.3.3, then found a binary package for 5.3.5 for my
distribution. Finally I compiled my own 5.3.6. The segmentation fault persists
in
all three versions.
If the Serializable interface is removed the code works fine.
Although the fault is reproducible, I found encountered other self-reference
scenarios where it is not triggered, making this very unpredictable.
Test script:
---------------
class Test implements Serializable {
public $member, $message;
function __construct($message) {
$this->message = $message;
}
function serialize() {
return serialize(array($this->message, $this->member));
}
function unserialize($serialized) {
list($this->message, $this->member) = unserialize($serialized);
}
}
$constructed = new Test("original");
$constructed->member = $constructed; //References to self (in this example
pointless, but technically legal)
var_dump($constructed);
$transported = unserialize(serialize($constructed)); // Segmentation fault.
Expected result:
----------------
Clean exit..
Actual result:
--------------
object(Test)#1 (2) {
["member"]=>
*RECURSION*
["message"]=>
string(8) "original"
}
Segmentation fault
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55219&edit=1