View Issue Details

IDProjectCategoryView StatusLast Update
0002265XdebugStacktracespublic2024-08-07 13:39
Reporterlucasbustamante Assigned Toderick  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionunable to reproduce 
Product Version3.3.1 
Summary0002265: Refletion consumes an exorbitating amount of resources if var_display_max_children and similars are unlimited or very high
Description

Reflection is used, for instance, on DI containers with autowiring.

For the DI Container to autowire, it needs to call ReflectionMethod($class, '__construct') to get an instance of the constructor.

This call becomes extremely expensive if Xdebug is active on "develop" mode and "var_display_max_children" is unlimited or very high, as per screenshot attached.

Steps To Reproduce
  • Set xdebug.mode to "develop,profile", and var_display_max_children, var_display_max_data, var_display_max_depth to either unlimited or very high.
  • Install a DI container with Autowiring, such as DI52 or other one from your preference.

Create two classes Foo and Bar:

class Foo {
protected Bar $bar;

public function __construct(Bar $bar) {
$this->bar = $bar; // Maybe constructor promotion can also replicate it, but I didn't try.
}
}

class Bar {}

  • Now build Foo, with $container->make(Foo::class);
  • Now open the profile that was generated and see that a high memory and time was spent on Reflection
  • Revert "var_displaymax" variables to defaults and try again, see that memory and time usage is normal
  • Do so preferably on the context of a big codebase where lots of things happened before getting to that point of execution.
Additional Information

This can be considered is a user error, since it only happens when "var_displaymax" is high, but I think some defensive programming can make Xdebug better here.

Probably related: https://bugs.xdebug.org/view.php?id=1988

TagsNo tags attached.
Operating System
PHP Version8.1.10-8.1.19

Activities

lucasbustamante

2024-05-03 19:58

reporter   ~0006931

Profiler screenshot:

image.png (50,181 bytes)   
image.png (50,181 bytes)   

derick

2024-05-06 10:38

administrator   ~0006942

Install a DI container with Autowiring, such as DI52 or other one from your preference.

I don't know what any of that means. Can you provide a full set of steps that allows me to reproduce this issue? Assume I know nothing about framework specific things.

derick

2024-07-17 18:11

administrator   ~0006999

Hi,

I am still waiting for the requested feedback. Can you please provide that?

cheers,
Derick

derick

2024-08-07 13:39

administrator   ~0007036

I can't reproduce this, and the requested feedback has not been forthcoming.

Issue History

Date Modified Username Field Change
2024-05-03 19:58 lucasbustamante New Issue
2024-05-03 19:58 lucasbustamante Note Added: 0006931
2024-05-03 19:58 lucasbustamante File Added: image.png
2024-05-06 10:38 derick Assigned To => derick
2024-05-06 10:38 derick Status new => feedback
2024-05-06 10:38 derick Note Added: 0006942
2024-07-17 18:11 derick Note Added: 0006999
2024-08-07 13:39 derick Status feedback => resolved
2024-08-07 13:39 derick Resolution open => unable to reproduce
2024-08-07 13:39 derick Note Added: 0007036