From 9ce51dad8bc0847f64b32fbbe623d79d49f6a5f0 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 21 Jul 2025 22:48:15 +0200 Subject: [PATCH] Add missing hooks JIT restart code Closes GH-19207. --- NEWS | 1 + ext/opcache/jit/zend_jit.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/NEWS b/NEWS index 409c613f6eb..aa2961a6ec3 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,7 @@ PHP NEWS - Opcache: . Reset global pointers to prevent use-after-free in zend_jit_status(). (Florian Engelhardt) + . Fix issue with JIT restart and hooks. (nielsdos) - OpenSSL: . Fixed bug GH-18986 (OpenSSL backend: incorrect RAND_{load,write}_file() diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index fd1203f086e..b0423dc06bd 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -3836,6 +3836,24 @@ static void zend_jit_restart_preloaded_script(zend_persistent_script *script) zend_jit_restart_preloaded_op_array(op_array); } } ZEND_HASH_FOREACH_END(); + + if (ce->num_hooked_props > 0) { + zend_property_info *prop; + + ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop) { + if (prop->hooks) { + for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) { + if (prop->hooks[i]) { + op_array = &prop->hooks[i]->op_array; + ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION); + if (!(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) { + zend_jit_restart_preloaded_op_array(op_array); + } + } + } + } + } ZEND_HASH_FOREACH_END(); + } } ZEND_HASH_FOREACH_END(); }