Skip to content

fix: system ID for Apache graceful restart - #24184

Open
morrisonlevi wants to merge 1 commit into
php:PHP-8.4from
morrisonlevi:system-id-reinitialization
Open

morrisonlevi wants to merge 1 commit into
php:PHP-8.4from
morrisonlevi:system-id-reinitialization

Conversation

@morrisonlevi

@morrisonlevi morrisonlevi commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

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, 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.


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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant