|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-07-16 23:46 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 15 00:00:02 2025 UTC |
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