Edit report at https://bugs.php.net/bug.php?id=55219&edit=1

 ID:                 55219
 Updated by:         maar...@php.net
 Reported by:        garic dot suess+php at gmail dot com
 Summary:            Segmentation fault with Serializable Object on
                     self-reference
-Status:             Verified
+Status:             Wont fix
 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:

Fixed in 5.4.0, see http://3v4l.org/XuJmX

PHP 5.3 is end of life per March 2013 ( http://php.net/releases/5_3_20.php ), 
so you should upgrade to 5.4. Given that the issue is 2 years old, you might 
just as well already have. ;)


Previous Comments:
------------------------------------------------------------------------
[2011-11-14 14:53:14] errebi at gmail dot com

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

------------------------------------------------------------------------
[2011-07-17 08:23:58] fel...@php.net

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] fel...@php.net

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

Reply via email to