[Parallel] Guard uninitialized encoder in ParallelProcess::quit() - #8461
Open
TomasVotruba wants to merge 1 commit into
Open
[Parallel] Guard uninitialized encoder in ParallelProcess::quit()#8461TomasVotruba wants to merge 1 commit into
TomasVotruba wants to merge 1 commit into
Conversation
A process spawned into the pool but not yet bound to its connection has no encoder set. When quitAll() runs after an error (e.g. timeout) it calls quit() on every pooled process, hitting "Typed property $encoder must not be accessed before initialization". Guard the encoder access. Fixes rectorphp/rector#9885 Claude-Session: https://claude.ai/code/session_01BhpDMF7ffeFv6sjaPqEZzc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes rectorphp/rector#9885
Problem
Running with a high
withParallel()worker count crashes near the end:Cause
A
ParallelProcessis spawned viastart()and attached to the pool immediately, but its$encoderis set only later inbindConnection(), once the child connects over TCP and sendsHELLO.When an error occurs (e.g. a job timeout),
handleErrorCallablecallsProcessPool::quitAll(), which invokesquit()on every pooled process, including those spawned but not yet bound. Those have no$encoder, so$this->encoder->end()throws.With many more workers than needed (the report uses
withParallel(360)), plenty of processes sit in the pool unbound whenquitAll()fires.Fix
Guard the encoder access in
quit()withisset(), so an unbound process quits cleanly.https://claude.ai/code/session_01BhpDMF7ffeFv6sjaPqEZzc