[php-src] PR #25482: Fix OPcache blacklist used after free when PHP starts again

From: Date: Mon, 16 Nov 2026 12:05:39 +0000
Subject: [php-src] PR #25482: Fix OPcache blacklist used after free when PHP starts again
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-40675@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25482 Author: nicolas-grekas zend_accel_blacklist_shutdown() frees the regexps and the entries of the blacklist, but keeps regexp_list and pos. The next startup in the same process only initializes the blacklist again when opcache.blacklist_filename is set. Without it, the first compiled file is matched against the freed regexps, and opcache_get_configuration() reads pos entries from a NULL array. Both crash. An embedder hits this when its configuration changes between two startups. I found it with the test suite of FrankenPHP, which starts PHP with a different php.ini for each test. With the embed SAPI (PHP 8.5 and up, where OPcache runs in any SAPI): ```c #include <sapi/embed/php_embed.h> int main(int argc, char **argv) { /* only the first one sets opcache.blacklist_filename */ char *ini[] = {"with-blacklist.ini", "without-blacklist.ini"}; for (int i = 0; i < 2; i++) { php_embed_module.php_ini_path_override = ini[i]; PHP_EMBED_START_BLOCK(argc, argv) zend_eval_string("include 'test.php';", NULL, "repro"); PHP_EMBED_END_BLOCK() } return 0; } ``` With test.php echoing ok, this prints ok once, then segfaults in zend_accel_blacklist_is_blacklisted(). With the patch, it prints ok twice. There's no test: run-tests can't start PHP twice in one process.

« previous php.git-pulls (#40675) next »