Skip to content

Fix opcache.interned_strings_buffer being 0 in threads started later (ZTS) - #24275

Open
pavimus wants to merge 1 commit into
php:PHP-8.4from
pavimus:fix-zts-ini-interned-strings
Open

pavimus wants to merge 1 commit into
php:PHP-8.4from
pavimus:fix-zts-ini-interned-strings

Conversation

@pavimus

@pavimus pavimus commented Oct 12, 2026

Copy link
Copy Markdown

Prepared with an AI assistant (Claude), which also ran the reproduction and the tests on my machine; I reviewed the result. The text below is AI-generated (quoted, as asked in CONTRIBUTING.md).

Under ZTS, threads started after OPcache's startup end up with opcache.interned_strings_buffer = 0 and log a warning each; a regression from GH-23309 (PHP 8.4.26).

Since GH-23309 (PHP 8.4.26) OnUpdateInternedStringsBuffer() rejects any change once OPcache is
set up. Under ZTS every thread started after OPcache's startup re-applies the INI entries with
ZEND_INI_STAGE_STARTUP into its own zeroed zend_accel_globals; the handler rejects that, logs a
warning for every new thread ("opcache.interned_strings_buffer cannot be changed when OPcache is
already set up.", seen once per thread in Apache error logs and FrankenPHP) and leaves the
directive at 0 in that thread (opcache_get_configuration() reports 0).

Accept the value at ZEND_INI_STAGE_STARTUP (the one SHM was set up with); changes at later
stages, like FPM pools (ZEND_INI_STAGE_ACTIVATE), are still rejected as intended by GH-23309.
Verified from a FrankenPHP worker thread: 0 -> 8, no warnings.

No test: the problem needs a thread started after startup (FrankenPHP, Apache threaded MPM).

🤖 Generated with Claude Code

…(ZTS)

Since phpGH-23309 OnUpdateInternedStringsBuffer() rejects any change once
OPcache is set up, to catch diverging php_admin_value settings of FPM
pools. Under ZTS every thread started after OPcache's startup re-applies
the INI entries with ZEND_INI_STAGE_STARTUP into its own, zeroed
zend_accel_globals; the handler rejects that as well, logs a warning
for every new thread and leaves ZCG(accel_directives).
interned_strings_buffer at 0 in that thread (e.g. opcache_get_configuration()
reports 0 under FrankenPHP and Apache mod_php with threaded MPMs).

Accept the value at ZEND_INI_STAGE_STARTUP: it is the value the shared
memory was set up with. Changes at later stages (FPM pools use
ZEND_INI_STAGE_ACTIVATE) are still rejected.
@pavimus

pavimus commented Oct 12, 2026

Copy link
Copy Markdown
Author

Prepared with an AI assistant (Claude); the text below is AI-generated (quoted, as asked in CONTRIBUTING.md).

Related: the same problem for opcache.memory_consumption on PHP 8.5 is GH-22216, with the identical fix in #22225 by @dkkoma. Both can go in together; when merging this one up into PHP-8.5 the two handlers end up with the same check.

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