#49194 [Opn->Asn]: var_dump() doesn't completely protect against infinite looping
ID: 49194
Updated by: colder@php.net
Reported By: gwynne@php.net
-Status: Open
+Status: Assigned
Bug Type: *General Issues
Operating System: *
PHP Version: 5.3, 6 (2009-08-07)
-Assigned To:
+Assigned To: colder
New Comment:
This is an inherent problem of the get_debug_info handler.
For closures which should (I guess) remain constant across multiple
var_dump calls, there is an easy solution of caching the HT.
http://patches.colder.ch/php-src/zend_closures_recursion-5.3.patch?markup
However, multiple mutable classes uses a custom debug_info handler with
full control over the items, such as SPLDoublyLinkedList. The problem
here seems to be impossible to fix without adapting the get_debug_info
handler.
Changing it from
HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp
TSRMLS_DC);
to
HashTable **(*zend_object_get_debug_info_t)(zval *object, int *is_temp
TSRMLS_DC);
should be sufficient.
Previous Comments:
------------------------------------------------------------------------
[2009-08-07 18:44:09] gwynne@php.net
Description:
------------
Calling var_dump() on a closure that references itself results in an
infinite loop.
Reproduce code:
---------------
<?php
$f = function () use (&$f) {};
var_dump($f);
?>
Expected result:
----------------
object(Closure)#1 (1) {
["static"]=>
array(1) {
["f"]=>
&object(Closure)#1 (1) {
["static"]=>
array(1) {
["f"]=>RECURSION
}
}
}
}
Actual result:
--------------
object(Closure)#1 (1) {
["static"]=>
array(1) {
["f"]=>
&object(Closure)#1 (1) {
["static"]=>
array(1) {
["f"]=>
&object(Closure)#1 (1) {
["static"]=>
array(1) {
["f"]=>
<repeats forever>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49194&edit=1
Thread (3 messages)