|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-07-14 11:00 UTC] dmitry@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: dmitry
[2016-07-14 11:00 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 08:00:02 2026 UTC |
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