-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Dependency Injection inifinite loop handling circular references consuming memory #39015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I optimized the way the loop are detected (see #39019 ) Note: this is not an infinite loops, but an exponential loop that consume a huge amount of memory |
Using 8gb of memory also breaks on my issue. The patch in #39021 does not fix the issue. Some more details on the error:
The code there looks like this:
It's always the same |
Hmm, this breaks since #3812 because now, a lazy service used a proxy. Which end in an infinity loop where the proxy is injected inside the proxy. this is fixed by https://github.com/symfony/symfony/compare/85d8004602f0b4e18999ade5cb8ecabfa6a06f42..d3b951b767e70a40c80ddbb9ebfcfe7518f14c81 could you give a try @soyuka ? @nicolas-grekas this second issue, shows that some lazy services MUST stop the loop detection, do you have other similar case in mind? |
…ving flattening (jderusse) This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Optimize circular collection by removing flattening | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39015 | License | MIT | Doc PR | - Alternative to #39019 Commits ------- e649f47 Optimize circular collection by removing flattening
…truct loop (jderusse) This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Fix circular in DI with lazy + byContruct loop | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39120 | License | MIT | Doc PR | - This fix another issue lazy service. It partially revert #38980 and #39021 Initially, we trusted lazy services to be lazy and not beeing called while building the services graph => bug #38970 when lazy deps is injected in a factory, it may be consumed directly to build the object before the graph is fully built Fixed by #38980 => lazy service are considered as "normal service" => bug #39015 some loop are not resolvable with "normal service", but it shouldn't be an issue when servie proxifyied Fixed by #39021 => lazy service are considered as "normal service" except when proxyfied => bug #39120 some loop are not resolvable with "normal service", but it shouldn't be an issue because the lazy service is injected in the constructor and user Fixed by this PR => that revert to the initial state. lazy service are trusted. But now, The IterratorArgument injected in a factory (single exception) is not more considered as lazy Commits ------- 54af139 [DependencyInjection] Fix circular in DI with lazy + byContruct loop
Symfony version(s) affected: 5.2.x
Description
Clearing the cache with latest symfony breaks on
api-platform/core
How to reproduce
This will lead to an out of memory error (be sure you don't use
memory_limit=-1
)Possible Solution
Revert the code changed in PhpDumper (see https://github.com/symfony/symfony/pull/38980/files#diff-82d7ebdd6477cecb404b0d3f100a9026e950529edb9a665460ae0330dfad7080L454)
If you reproduced and want to try the fix, just
rm -rf tests/Fixtures/app/var/cache/
and use the command again.ref: #38980
The text was updated successfully, but these errors were encountered: