Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13709 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62333 invoked by uid 1010); 3 Nov 2004 15:12:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 62265 invoked from network); 3 Nov 2004 15:12:49 -0000 Received: from unknown (HELO iko.gotobg.net) (80.168.8.116) by pb1.pair.com with SMTP; 3 Nov 2004 15:12:49 -0000 Received: from pd95e9886.dip.t-dialin.net ([217.94.152.134] helo=[192.168.0.36]) by iko.gotobg.net with esmtpa (Exim 4.43) id 1CPMoc-0005rI-Sv; Wed, 03 Nov 2004 17:12:51 +0200 Message-ID: <4188F4CC.6000902@hristov.com> Date: Wed, 03 Nov 2004 16:10:04 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a4) Gecko/20040918 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Francisco M. Marzoa Alonso" CC: internals References: <4188DEC8.5060309@gmx.net> <4188DDC9.30000@hristov.com> <4189013F.2050104@gmx.net> In-Reply-To: <4189013F.2050104@gmx.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] serialize bug with array that references to itself? From: php@hristov.com (Andrey Hristov) Feel free to file a bug report at http://bugs.php.net .Mention in the subject there there is core dump. Thanks, Andrey Francisco M. Marzoa Alonso wrote: > Should I fill a bug notification report or so? (where are them? ;-)) > > Andrey Hristov wrote: > >> Francisco M. Marzoa Alonso wrote: >> >>> Try this code: >>> >>>
>>> >>
>>> $Arr = array();
>>> $Arr['self'] = &$Arr;
>>> var_dump ( $Arr );
>>>
>>> $serdata = serialize ($Arr);
>>> $Arr2 = unserialize ( $serdata );
>>> echo "\n\n";
>>> var_dump ( $Arr2 );
>>>
>>> ?>
>>> 
>>> >>> The second array is expected to be exactly as $Arr, but it doesn't. >>> This is the output for that code: >>> >>> array(1) { >>> ["self"]=> >>> array(1) { >>> ["self"]=> >>> *RECURSION* >>> } >>> } >>> >>> array(1) { >>> ["self"]=> >>> array(1) { >>> ["self"]=> >>> NULL >>> } >>> } >>> >>> As you can see the second array has a NULL value where the first one >>> had a recursive reference. >>> >>> Can this be considered as a bug of PHP serialization system? >>> >> >> Looks as such. >> While looking at this one, I cooked a little example which cores ZE2 >> (5.1.0-dev) >> >> > class a{} >> class b{} >> >> $a=new a; >> $b=new b; >> $a->a=$b; >> $c=array($a,$b); >> var_dump($c,$d=serialize($c)); >> var_dump($e=unserialize($d)); >> $d[0]->a->prop=1; >> var_dump($d); >> ?> >> >> If one looks at it she will see that I have an error in the example >> and instead >> of $d[0]->a I have to use $e[0] , still a Segmentation Fault is not >> tolerable. >> >> This works ok : >> > class a{} >> class b{} >> >> $a=new a; >> $b=new b; >> $a->a=$b; >> $c=array($a,$b); >> var_dump($c, $d=serialize($c)); >> var_dump($e=unserialize($d)); >> $d[0]->a->prop=1; >> var_dump($d); >> ?> >> >> $e is : >> array(2) { >> [0]=> >> object(a)#3 (1) { >> ["a"]=> >> object(b)#4 (1) { >> ["prop"]=> >> int(1) >> } >> } >> [1]=> >> object(b)#4 (1) { >> ["prop"]=> >> int(1) >> } >> } >> >> Andrey >> >