Repository navigation
fix: system ID for Apache graceful restart - #24184
Open
morrisonlevi wants to merge 1 commit into
Open
morrisonlevi wants to merge 1 commit into
morrisonlevi wants to merge 1 commit into
Conversation
Apache forks workers from a parent process. During a graceful restart, PHP shuts down and starts up again in that same parent process. However, `finalized` was not reset to 0 during subsequent startups, so all calls to `zend_add_system_entropy()` would fail. This could cause the process state to diverge from the system ID used to validate OPcache's file cache. For example, `zend_get_resource_handle()` would still allocate a handle, but its entropy would not contribute to the system ID. Enabling, disabling, or reordering extensions or features across graceful restarts could therefore change resource-slot assignments without a corresponding change to the system ID. Reset `finalized` when initializing the system ID so each startup can register fresh entropy.
morrisonlevi
marked this pull request as ready for review
October 7, 2026 23:12
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.
Apache forks workers from a parent process. During a graceful restart, PHP shuts down and starts up again in that same parent process. New workers are then forked from the parent.
However,
finalizedwas not reset to 0 during subsequent startups, so all calls tozend_add_system_entropy()would fail. This could cause the process state to diverge from the system ID used to validate OPcache's file cache.For example,
zend_get_resource_handle()would still allocate a handle, but its entropy would not contribute to the system ID. Enabling, disabling, or reordering extensions or features across graceful restarts could therefore change resource-slot assignments without a corresponding change to the system ID.Reset
finalizedwhen initializing the system ID so each startup can register fresh entropy.I think this fix should definitely go into PHP 8.4+ but I think that RMs should consider pulling it for 8.2-8.3. It is not a dangerous change, it's simple, and easy to understand (well, assuming you already understand Apache graceful and system ID), and causes really nasty memory bugs when it's hit.