Bug #68464 [NEW]: Undetected recursion when using __debugInfo()

From: Date: Thu, 20 Nov 2014 19:15:28 +0000
Subject: Bug #68464 [NEW]: Undetected recursion when using __debugInfo()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188718@lists.php.net to get a copy of this message
From: dev at pp3345 dot net Operating system: Debian 7 Wheezy PHP version: 5.6.3 Package: Scripting Engine problem Bug Type: Bug Bug description:Undetected recursion when using __debugInfo() 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 bug report at https://bugs.php.net/bug.php?id=68464&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68464&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68464&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68464&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68464&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68464&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68464&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68464&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68464&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68464&r=support Expected behavior: https://bugs.php.net/fix.php?id=68464&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68464&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68464&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68464&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68464&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68464&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68464&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68464&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68464&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68464&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68464&r=mysqlcfg

« previous php.bugs (#188718) next »