View Issue Details

IDProjectCategoryView StatusLast Update
0001166XdebugUncategorizedpublic2015-11-05 15:13
Reporterplankmeister Assigned Toderick  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Fixed in Version2.4.0beta1 
Summary0001166: Using $this in __debugInfo() causes infinite recursion (Doesn't appear to be the same as issue 0001140)
Description

When debugging with Xdebug 2.3.3 on PHP 5.6.9, stepping into an object that has a defined debugInfo() method that refers to $this causes an uncaught LogicException; 'The object is in an invalid state as the parent constructor was not called'
When single-stepping, the moment the first expression in the constructor is stepped into, execution skips to the
debugInfo() method, where it dies upon encountering $this.

Steps To Reproduce

php -dxdebug.auto_trace=1 -dxdebug.collect_params=3 -r 'class Foo extends IteratorIterator{function __construct($items){if(is_array($items)){$items=new ArrayIterator($items);}}function __debugInfo(){return ["count"=>iterator_count($this)];}};$a=new Foo([1,2,3]);var_dump($a);'

Additional Information

Output extract:

PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP Warning: Uncaught exception 'LogicException' with message 'The object is in an invalid state as the parent constructor was not called' in Command line code:1
Stack trace:
#0 [internal function]: IteratorIterator->rewind()
#1 Command line code(1): iterator_count(Object(Foo))
0000002 [internal function]: Foo->debugInfo()
0000003 [internal function]: IteratorIterator->rewind()
0000004 Command line code(1): iterator_count(Object(Foo))
0000005 [internal function]: Foo->__debugInfo()
0000006 [internal function]: IteratorIterator->rewind()
0000007 Command line code(1): iterator_count(Object(Foo))
0000008 [internal function]: Foo->
debugInfo()
0000009 [internal function]: IteratorIterator->rewind()
0000010 Command line code(1): iterator_count(Object(Foo))
0000011 [internal function]: Foo->__debugInfo()
0000012 [internal function]: IteratorIterator->rewind()
0000013 Command line code(1): iterator_count(Object(Foo))
0000014 [internal function]: Foo->__debugInfo()
0000015 [internal function]: IteratorIterator->rewind()
0000016 Command line code(1): iterator_count(Object(Foo))
0000017 [internal fu in Command line code on line 1

TagsNo tags attached.
Operating SystemDebian GNU/Linux 7.8 (wheezy)
PHP Version5.5.15-5.5.19

Activities

plankmeister

2015-06-22 21:16

reporter   ~0003127

The actual Class in production code that produces the issue is https://github.com/cakephp/cakephp/blob/3.1/src/Collection/Collection.php if the context is important.

derick

2015-06-25 13:43

administrator   ~0003138

Thanks - I can reproduce this with your reproduce script. Thanks for making it so short! I'll have a look.

derick

2015-06-28 15:11

administrator   ~0003142

Fixed for 2.3.4 and 3.0dev

Issue History

Date Modified Username Field Change
2015-06-22 21:13 plankmeister New Issue
2015-06-22 21:16 plankmeister Note Added: 0003127
2015-06-25 13:43 derick Note Added: 0003138
2015-06-28 15:11 derick Note Added: 0003142
2015-06-28 15:11 derick Status new => closed
2015-06-28 15:11 derick Assigned To => derick
2015-06-28 15:11 derick Resolution open => fixed
2015-06-28 15:11 derick Fixed in Version => 2.3.4
2015-11-05 15:08 derick Fixed in Version 2.3.4 => 2.4.0beta1
2015-11-05 15:13 derick Category Debug client (console) => Usage problems
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized