[php-src] PHP-8.6: Fix opcache.interned_strings_buffer being 0 in threads started later (ZTS)

From: Date: Fri, 30 Oct 2026 09:54:13 +0000
Subject: [php-src] PHP-8.6: Fix opcache.interned_strings_buffer being 0 in threads started later (ZTS)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142990@lists.php.net to get a copy of this message
Author: Pavel Gushcha (pavimus) Committer: ndossche (ndossche) Date: 2026-10-30T10:53:13+01:00 Commit: https://github.com/php/php-src/commit/38eabd0452df61e4d871f38e8afe2306490dd3b4 Raw diff: https://github.com/php/php-src/commit/38eabd0452df61e4d871f38e8afe2306490dd3b4.diff Fix opcache.interned_strings_buffer being 0 in threads started later (ZTS) Since GH-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. Closes GH-24275. Changed paths: M NEWS M ext/opcache/zend_accelerator_module.c Diff: diff --git a/NEWS b/NEWS index d84ff40a31a6..14df7132c7c2 100644 --- a/NEWS +++ b/NEWS @@ -187,6 +187,8 @@ PHP NEWS (ndossche, khaledalam) . Fix preloaded functions JIT-compiled on load being overwritten after restart. (Pavel Gushcha) + . Fix opcache.interned_strings_buffer being 0 in threads started later (ZTS). + (Pavel Gushcha) - OpenSSL: . Fixed bug GH-24784 (openssl_pkcs7_read() and openssl_cms_read() overwrite diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 23192e8950bf..902d69374bb7 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -93,7 +93,12 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption) static ZEND_INI_MH(OnUpdateInternedStringsBuffer) { - if (accel_startup_ok) { + /* Under ZTS, every thread started later re-applies the INI entries at + * ZEND_INI_STAGE_STARTUP to fill its own globals. Accepting that is safe: the + * value comes from the global INI directives, so it is the one OPcache was + * set up with. NTS does not have this problem: STARTUP handlers run before + * accel_startup_ok is set, and accel_shutdown() clears it again. */ + if (accel_startup_ok && stage != ZEND_INI_STAGE_STARTUP) { if (strcmp(sapi_module.name, "fpm-fcgi") == 0) { zend_accel_error(ACCEL_LOG_WARNING, "opcache.interned_strings_buffer cannot be changed when OPcache is already set up. Are you using php_admin_value[opcache.interned_strings_buffer] in an individual pool's configuration?\n"); } else {

« previous php.cvs (#142990) next »