From d3007fcfe8a41305fa5c0a8e185cbb83405a4d1c Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Thu, 29 Oct 2026 21:30:31 +0100 Subject: [PATCH] Fix preloaded functions not JIT-compiled again after OPcache restart zend_jit_restart_hot_counters() restored the hot counters but kept ZEND_FUNC_JITED, so zend_jit_hot_func() never compiled the function again. With opcache.jit_hot_func=1 this loops forever. --- ext/opcache/jit/zend_jit.c | 2 + .../jit/preload_restart_hot_counters.phpt | 76 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 ext/opcache/tests/jit/preload_restart_hot_counters.phpt diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 679b7db269f9..67e3e741551b 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -3124,6 +3124,8 @@ static int zend_jit_restart_hot_counters(zend_op_array *op_array) uint32_t i; jit_extension = (zend_jit_op_array_hot_extension*)ZEND_FUNC_INFO(op_array); + /* The JIT-ed code is gone, so allow compiling it again */ + jit_extension->func_info.flags &= ~ZEND_FUNC_JITED; for (i = 0; i < op_array->last; i++) { op_array->opcodes[i].handler = jit_extension->orig_handlers[i]; } diff --git a/ext/opcache/tests/jit/preload_restart_hot_counters.phpt b/ext/opcache/tests/jit/preload_restart_hot_counters.phpt new file mode 100644 index 000000000000..8f6af56b1671 --- /dev/null +++ b/ext/opcache/tests/jit/preload_restart_hot_counters.phpt @@ -0,0 +1,76 @@ +--TEST-- +Preloaded functions JIT-compiled by hot counters must be JIT-compiled again after an OPcache restart +--EXTENSIONS-- +opcache +--SKIPIF-- + +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit=1235 +opcache.jit_buffer_size=16M +--CONFLICTS-- +server +--FILE-- +> 2); + } + return $s; +} +PHP); + +/* A dynamic call keeps the function out of the call graph of the calling script */ +file_put_contents($dir . '/call.php', <<<'PHP' + ['timeout' => 5]]); +foreach (['call', 'reset', 'call', 'call'] as $script) { + echo @file_get_contents($base . $script . '.php', false, $context) ?: "no response\n"; +} +?> +--CLEAN-- + +--EXPECT-- +1502868 +bool(true) +bool(true) +1502868 +1502868