[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
| From: | ndossche | Date: | Mon, 28 Sep 2026 21:20:19 +0000 |
| Subject: | [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141643@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-09-28T23:19:43+02:00
Commit: https://github.com/php/php-src/commit/ecb17a0616ce00991750693e2b7990ad79c7df17
Raw diff: https://github.com/php/php-src/commit/ecb17a0616ce00991750693e2b7990ad79c7df17.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
Fix incorrect DCE due to unsound escape analysis
Changed paths:
A ext/opcache/tests/opt/dce_015.phpt
M NEWS
M Zend/Optimizer/escape_analysis.c
Diff:
diff --git a/NEWS b/NEWS
index ba65b8a7c263..23a8d2d3c8a1 100644
--- a/NEWS
+++ b/NEWS
@@ -78,6 +78,7 @@ PHP NEWS
proxy objects instead of forwarding to the real instance). (lisachenko)
. Fixed bug GH-23679 (Tracing JIT writes a parent private property into a
child's shadowing public property). (Ilia Alshanetsky)
+ . Fix incorrect DCE due to unsound escape analysis. (ndossche)
- PCNTL:
. Fixed pcntl_signal_dispatch() dropping the queued signals when it runs while
diff --git a/Zend/Optimizer/escape_analysis.c b/Zend/Optimizer/escape_analysis.c
index 840a18341a0f..352d647e925b 100644
--- a/Zend/Optimizer/escape_analysis.c
+++ b/Zend/Optimizer/escape_analysis.c
@@ -300,8 +300,10 @@ static bool is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int
v
case ZEND_ASSIGN_STATIC_PROP_OP:
case ZEND_ASSIGN_DIM:
case ZEND_ASSIGN_OBJ:
- case ZEND_ASSIGN_OBJ_REF:
break;
+ case ZEND_ASSIGN_OBJ_REF:
+ /* The property may now alias a variable outside of the object. */
+ return true;
case ZEND_PRE_INC_OBJ:
case ZEND_PRE_DEC_OBJ:
case ZEND_POST_INC_OBJ:
diff --git a/ext/opcache/tests/opt/dce_015.phpt b/ext/opcache/tests/opt/dce_015.phpt
new file mode 100644
index 000000000000..a09284cab369
--- /dev/null
+++ b/ext/opcache/tests/opt/dce_015.phpt
@@ -0,0 +1,45 @@
+--TEST--
+DCE must not remove assignments to properties of an object holding a reference
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+
+class Holder {
+ public $untyped = 0;
+ public int $typed = 0;
+}
+
+class Target {
+ public $untyped = 0;
+ public int $typed = 0;
+}
+
+function untyped() {
+ $h = new Holder;
+ $t = new Target;
+ $h->untyped = &$t->untyped;
+ $h->untyped = 5;
+ var_dump($t->untyped);
+}
+
+function typed() {
+ $h = new Holder;
+ $t = new Target;
+ $h->typed = &$t->typed;
+ $h->typed = 5;
+ var_dump($t->typed);
+}
+
+untyped();
+typed();
+
+?>
+--EXPECT--
+int(5)
+int(5)