[php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Weilin Du | Date: | Sun, 08 Nov 2026 16:34:44 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143451@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-11-09T00:30:14+08:00
Commit: https://github.com/php/php-src/commit/83dc19cad4701aedb9a83d4749a6075a493a1b1f
Raw diff: https://github.com/php/php-src/commit/83dc19cad4701aedb9a83d4749a6075a493a1b1f.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix GH-25253: JIT reads parent of an unlinked class (#25259)
Changed paths:
A ext/opcache/tests/jit/gh25253.inc
A ext/opcache/tests/jit/gh25253.phpt
M NEWS
M ext/opcache/jit/zend_jit.c
Diff:
diff --git a/NEWS b/NEWS
index b4a8604a37c5..bf00cb946a70 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,8 @@ PHP NEWS
SHM backend). (Lazizbek Ergashev)
. Fixed bug GH-25269 (JIT: misaligned zval passed to
ZEND_ADD_ARRAY_ELEMENT handler). (Jorg Sowa, ndossche)
+ . Fixed bug GH-25253 (JIT reads parent of an unlinked class).
+ (lazerg, mlenarciak)
- OpenSSL:
. Fixed bug GH-25172 (TLS session reuse shares request-lifetime callback
diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index ff40b1380a64..7e3afe8ff8af 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 @@
+<?php
+
+class GH25253Child extends GH25253ParentClass {
+ public function m0() { return parent::m0(); }
+ public function m1() { return parent::m1(); }
+ public function m2() { return parent::m2(); }
+ public function m3() { return parent::m3(); }
+ public function m4() { return parent::m4(); }
+ public function m5() { return parent::m5(); }
+}
diff --git a/ext/opcache/tests/jit/gh25253.phpt b/ext/opcache/tests/jit/gh25253.phpt
new file mode 100644
index 000000000000..eb6c7c525ffc
--- /dev/null
+++ b/ext/opcache/tests/jit/gh25253.phpt
@@ -0,0 +1,30 @@
+--TEST--
+GH-25253: JIT reads parent of an unlinked class
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+opcache.interned_strings_buffer=0
+opcache.jit=function
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+
+class GH25253ParentClass {
+ public function m0() { return 'm0'; }
+ public function m1() { return 'm1'; }
+ public function m2() { return 'm2'; }
+ public function m3() { return 'm3'; }
+ public function m4() { return 'm4'; }
+ public function m5() { return 'm5'; }
+}
+
+require __DIR__ . '/gh25253.inc';
+
+$c = new GH25253Child;
+echo $c->m0(), $c->m5(), "\n";
+
+?>
+--EXPECT--
+m0m5