From 58abe039d75c4506750c133843b4afbe15e1da7d Mon Sep 17 00:00:00 2001 From: lazerg Date: Sat, 7 Nov 2026 06:01:44 +0500 Subject: [PATCH] Fix GH-25253: JIT reads parent of an unlinked class Co-authored-by: mlenarciak <39970740+mlenarciak@users.noreply.github.com> --- ext/opcache/jit/zend_jit.c | 2 +- ext/opcache/tests/jit/gh25253.inc | 10 ++++++++++ ext/opcache/tests/jit/gh25253.phpt | 30 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/jit/gh25253.inc create mode 100644 ext/opcache/tests/jit/gh25253.phpt diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 1490c43e5b77..ff016ad8ff12 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -592,7 +592,7 @@ static zend_class_entry* zend_get_known_class(const zend_op_array *op_array, con ZEND_ASSERT((op.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_PARENT); ce = op_array->scope; if (ce) { - if (ce->parent) { + if ((ce->ce_flags & ZEND_ACC_LINKED) && ce->parent) { ce = ce->parent; if (ce->type == ZEND_INTERNAL_CLASS || ce->info.user.filename != op_array->filename) { ce = NULL; diff --git a/ext/opcache/tests/jit/gh25253.inc b/ext/opcache/tests/jit/gh25253.inc new file mode 100644 index 000000000000..64db08b7513d --- /dev/null +++ b/ext/opcache/tests/jit/gh25253.inc @@ -0,0 +1,10 @@ +m0(), $c->m5(), "\n"; + +?> +--EXPECT-- +m0m5