Bug #68464 [Opn->Csd]: Undetected recursion when using __debugInfo()
| From: | dmitry@php.net | Date: | Thu, 14 Jul 2016 11:00:49 +0000 |
| Subject: | Bug #68464 [Opn->Csd]: Undetected recursion when using __debugInfo() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202308@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68464&edit=1
ID: 68464
Updated by: dmitry@php.net
Reported by: dev at pp3345 dot net
Summary: Undetected recursion when using __debugInfo()
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Debian 7 Wheezy
PHP Version: 5.6.3
-Assigned To:
+Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
The bug has been fixed in PHP-7.0.
Previous Comments:
------------------------------------------------------------------------
[2014-11-20 19:15:27] dev at pp3345 dot net
Description:
------------
Hello,
it seems that the recursion detection for var_dump() doesn't work when using objects with
__debugInfo(), which causes an infinite loop. The problem seems to be located in
ext/standard/var.c:129:
myht = Z_OBJDEBUG_PP(struc, is_temp);
if (myht && ++myht->nApplyCount > 1) {
PUTS("*RECURSION*\n");
--myht->nApplyCount;
return;
}
Z_OBJDEBUG_PP() gives either a hashtable containing all properties of an object or, if __debugInfo()
is available, the hashtable returned by that method. Since this hashtable is recreated on every call
to __debugInfo(), changing it's nApplyCount value won't help for detecting object
recursion. Probably the objprop hashtable should always be used for recursion detection.
Test script:
---------------
<?php
class A {
public $x = null;
public function __debugInfo() {
return ["x" => $this->x];
}
}
class B {
public $y = null;
public function __debugInfo() {
return ["y" => $this->y];
}
}
$a = new A;
$a->x = new B;
$a->x->y = $a;
var_dump($a);
Expected result:
----------------
object(A)#1 (1) {
["x"]=>
object(B)#2 (1) {
["y"]=>
*RECURSION*
}
}
Actual result:
--------------
Infinite loop
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68464&edit=1