MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001296XdebugUsage problems (Wrong Results)public2016-04-26 12:222017-03-04 10:45
Reportergreew 
Assigned Toderick 
PriorityhighSeveritymajorReproducibilityhave not tried
StatusresolvedResolutionno change required 
PlatformMacOSOS X El CapitanOS Version10.11.4 (15E65)
Product Version2.4.0 
Target VersionFixed in Version 
Summary0001296: Using $this in __debugInfo() causes issues
DescriptionWhen debugging with Xdebug 2.4.0 on PHP 7.0.5, 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 Reproducephp -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 Information13:17 $ 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);'
PHP Warning: Uncaught LogicException: 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 Command line code(1): var_dump(Object(Foo))
0000004 {main}
  thrown in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. var_dump(class Foo { }) Command line code:1

Warning: Uncaught LogicException: 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 Command line code(1): var_dump(Object(Foo))
0000004 {main}
  thrown in Command line code on line 1

Call Stack:
    0.0005 349104 1. {main}() Command line code:0
    0.0013 349296 2. var_dump(class Foo { }) Command line code:1

PHP Fatal error: __debuginfo() must return an array in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. var_dump(class Foo { }) Command line code:1

Fatal error: __debuginfo() must return an array in Command line code on line 1

Call Stack:
    0.0005 349104 1. {main}() Command line code:0
    0.0013 349296 2. var_dump(class Foo { }) Command line code:1

?-255 ~
TagsNo tags attached.
Operating SystemOS X
PHP Version7.0.0-7.0.4
Attached Files

- Relationships

-  Notes
(0003619)
derick (administrator)
2016-05-29 09:13

I am not sure how this creates "infinite recursion", but I can reproduce your
output. I will need to investigate this.
(0003620)
greew (reporter)
2016-05-29 12:41

No, I thoughtlessly copied the title of the issue, that I also referenced in the title - but too late I remembered to change it.
Sorry about that :)
(0003621)
greew (reporter)
2016-05-29 12:44

Just tried reproducing it again in PHP 7.0.6 and XDebug 2.5.0-dev - still an issue.

13:43 $ 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);'
PHP Warning: Uncaught LogicException: 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 Command line code(1): var_dump(Object(Foo))
0000004 {main}
  thrown in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. var_dump(class Foo { }) Command line code:1

Warning: Uncaught LogicException: 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 Command line code(1): var_dump(Object(Foo))
0000004 {main}
  thrown in Command line code on line 1

Call Stack:
    0.0010 350840 1. {main}() Command line code:0
    0.0032 351032 2. var_dump(class Foo { }) Command line code:1

PHP Fatal error: __debuginfo() must return an array in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. var_dump(class Foo { }) Command line code:1

Fatal error: __debuginfo() must return an array in Command line code on line 1

Call Stack:
    0.0010 350840 1. {main}() Command line code:0
    0.0032 351032 2. var_dump(class Foo { }) Command line code:1
(0003908)
derick (administrator)
2016-12-04 15:50

I can reproduce this issue still with PHP 7.0.13 and Xdebug 2.5.0RC2-dev.
(0004185)
derick (administrator)
2017-01-14 18:23

I tried this again, this time *without* Xdebug loaded (see the -n), and the result is exactly the same:

derick@whisky:~/dev/php/derickr-xdebug $ cat tests/bug01296.phpt
--TEST--
Test for bug 0001296: Using $this in __debugInfo() causes issues
--FILE--
<?php
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 );
[GIT: issue1296-debuginfo][PHP: 7.0.13-dev ]
derick@whisky:~/dev/php/derickr-xdebug $ php -n tests/bug01296.phpt
--TEST--
Test for bug 0001296: Using $this in __debugInfo() causes issues
--FILE--

Warning: Uncaught LogicException: The object is in an invalid state as the parent constructor was not called in /home/derick/dev/php/derickr-xdebug/tests/bug01296.phpt:17
Stack trace:
#0 [internal function]: IteratorIterator->rewind()
#1 /home/derick/dev/php/derickr-xdebug/tests/bug01296.phpt(17): iterator_count(Object(Foo))
0000002 [internal function]: Foo->__debugInfo()
0000003 /home/derick/dev/php/derickr-xdebug/tests/bug01296.phpt(22): var_dump(Object(Foo))
0000004 {main}
  thrown in /home/derick/dev/php/derickr-xdebug/tests/bug01296.phpt on line 17

Fatal error: __debuginfo() must return an array in /home/derick/dev/php/derickr-xdebug/tests/bug01296.phpt on line 22


So I fail to see why this is an Xdebug issue. Can you clarify please?
(0004204)
derick (administrator)
2017-02-07 17:11

Ping?
(0004227)
derick (administrator)
2017-03-04 10:45

Closing this as no additional feedback was provided, and the behaviour was the same without Xdebug loaded.

- Issue History
Date Modified Username Field Change
2016-04-26 12:22 greew New Issue
2016-05-29 09:13 derick Note Added: 0003619
2016-05-29 09:13 derick Assigned To => derick
2016-05-29 09:13 derick Status new => acknowledged
2016-05-29 12:41 greew Note Added: 0003620
2016-05-29 12:44 greew Note Added: 0003621
2016-07-31 13:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 13:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2016-12-04 15:50 derick Note Added: 0003908
2016-12-04 15:50 derick Status acknowledged => confirmed
2017-01-14 17:38 derick Summary Using $this in __debugInfo() causes infinite recursion (see 0001166) => Using $this in __debugInfo() causes issues
2017-01-14 18:23 derick Note Added: 0004185
2017-01-14 18:23 derick Status confirmed => feedback
2017-02-07 17:11 derick Note Added: 0004204
2017-03-04 10:45 derick Note Added: 0004227
2017-03-04 10:45 derick Status feedback => resolved
2017-03-04 10:45 derick Resolution open => no change required


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker