[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Ilia Alshanetsky | Date: | Fri, 25 Sep 2026 12:35:29 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141538@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-25T08:32:00-04:00
Commit: https://github.com/php/php-src/commit/3e6ddcb02555d29b8b71ece223f907f63b4091e8
Raw diff: https://github.com/php/php-src/commit/3e6ddcb02555d29b8b71ece223f907f63b4091e8.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
ext/opcache: Fix GH-23679 tracing JIT shadowed private writes
Changed paths:
A ext/opcache/tests/jit/gh23679.phpt
M NEWS
M ext/opcache/jit/zend_jit.c
Diff:
diff --git a/NEWS b/NEWS
index 5e233c1b8182..0d1d864e52a3 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ PHP NEWS
- Opcache:
. Fix zend_analyze_calls() call_stack buffer overrun. (Mrmaxmeier)
+ . Fixed bug GH-23679 (Tracing JIT writes a parent private property into a
+ child's shadowing public property). (Ilia Alshanetsky)
24 Sep 2026, PHP 8.6.0RC2
diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index 85109c7d0e03..d778beb96e58 100644
--- a/ext/opcache/jit/zend_jit.c
+++ b/ext/opcache/jit/zend_jit.c
@@ -650,6 +650,11 @@ static zend_property_info* zend_get_known_property_info(const zend_op_array
*op_
}
if (info->flags & ZEND_ACC_PUBLIC) {
+ if ((info->flags & ZEND_ACC_CHANGED)
+ && op_array->scope
+ && op_array->scope != ce) {
+ return NULL;
+ }
return info;
} else if (on_this) {
if (ce == info->ce) {
diff --git a/ext/opcache/tests/jit/gh23679.phpt b/ext/opcache/tests/jit/gh23679.phpt
new file mode 100644
index 000000000000..8b3c65c6567f
--- /dev/null
+++ b/ext/opcache/tests/jit/gh23679.phpt
@@ -0,0 +1,116 @@
+--TEST--
+GH-23679: tracing JIT must not write a parent private property into a child's shadowing public
property
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+opcache.protect_memory=1
+opcache.jit=tracing
+opcache.jit_hot_loop=1
+opcache.jit_hot_func=1
+opcache.jit_hot_return=1
+opcache.jit_hot_side_exit=1
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+class A
+{
+ private $arr = [];
+ private $n = 0;
+
+ public function setDim($k, $v)
+ {
+ $x = clone $this;
+ $x->arr[$k] = $v;
+ return $x;
+ }
+
+ public function setAll($v)
+ {
+ $x = clone $this;
+ $x->arr = $v;
+ return $x;
+ }
+
+ public function inc()
+ {
+ $x = clone $this;
+ $x->n++;
+ return $x;
+ }
+
+ public function addN($k)
+ {
+ $x = clone $this;
+ $x->n += $k;
+ return $x;
+ }
+
+ public function getDim($k)
+ {
+ return $this->arr[$k] ?? 'MISSING';
+ }
+
+ public function getN()
+ {
+ return $this->n;
+ }
+}
+
+class B extends A
+{
+ public $arr = [];
+ public $n = 100;
+}
+
+for ($i = 0; $i < 50; $i++) {
+ (new A)->setDim('x', 1)->getDim('x');
+ (new A)->setAll(['x' => 1])->getDim('x');
+ (new A)->inc()->getN();
+ (new A)->addN(5)->getN();
+
+ $b = new B;
+ $b->arr = ['keep' => 1];
+ $b->n = 100;
+
+ $r = $b->setDim('x', 2);
+ if ($r->getDim('x') !== 2 || $r->arr !== ['keep' => 1]) {
+ echo "dim-assign i=$i private=";
+ var_dump($r->getDim('x'));
+ echo "dim-assign i=$i public=";
+ var_dump($r->arr);
+ exit(1);
+ }
+
+ $r = $b->setAll(['y' => 4]);
+ if ($r->getDim('y') !== 4 || $r->arr !== ['keep' => 1]) {
+ echo "assign i=$i private=";
+ var_dump($r->getDim('y'));
+ echo "assign i=$i public=";
+ var_dump($r->arr);
+ exit(1);
+ }
+
+ $r = $b->inc();
+ if ($r->getN() !== 1 || $r->n !== 100) {
+ echo "inc i=$i private=";
+ var_dump($r->getN());
+ echo "inc i=$i public=";
+ var_dump($r->n);
+ exit(1);
+ }
+
+ $r = $b->addN(5);
+ if ($r->getN() !== 5 || $r->n !== 100) {
+ echo "assign-op i=$i private=";
+ var_dump($r->getN());
+ echo "assign-op i=$i public=";
+ var_dump($r->n);
+ exit(1);
+ }
+}
+echo "ok\n";
+?>
+--EXPECT--
+ok