Rector Halts and Leaks Memory During Interaction of AddDefaultValueForUndefinedVariable
(5.6), IfToSpaceship
(7.0), and ClosureToArrowFunction
(7.4)
#7904
Labels
Bug Report
0.15.18
,0.15.24
, and0.15.25
When using the following three rules together, Rector halts upon encountering a
uasort
that satisfiesIfToSpaceshipRector
, then begins rapidly consuming memory until it hits the limit or the host crashes:AddDefaultValueForUndefinedVariableRector
IfToSpaceshipRector
ClosureToArrowFunctionRector
This was initially discovered when using
LevelSetList::UP_TO_PHP_82
.EDIT: It may also be note-worthy that when this happens, the user can Ctrl+C to end the process. When running again without
--clear-cache
, the issue will not re-occur in the same file but the rules will be skipped. The issue will re-occur if another file has the same issue or if--clear-cache
is provided.Minimal PHP Code Causing Issue
https://getrector.com/demo/dd221fce-626a-4664-9f07-c16fc5ff68aa
Based on this demo, the issue only seems to occur when the
IfToSpaceshipRector
andClosureToArrowFunction
interact as a function parameter. Individually, all rules work normally. When not nested inside a function call, the interaction of the latter two rules still works as expected.I'm not sure why
AddDefaultValueForUndefinedVariableRector
is required for reproduction, but removing it or adding it to the skip list fixes the crash.Expected Behaviour
The minimum error demo above should be refactored to:
I appreciate your time!
The text was updated successfully, but these errors were encountered: