[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | ndossche | Date: | Wed, 28 Oct 2026 22:12:27 +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-142901@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-10-28T23:12:13+01:00
Commit: https://github.com/php/php-src/commit/2b6a3011b2e084833670561a31fa0b6f1eb39953
Raw diff: https://github.com/php/php-src/commit/2b6a3011b2e084833670561a31fa0b6f1eb39953.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix block pass dropping ZEND_FAST_CALL OP2 definition
Changed paths:
A ext/opcache/tests/opt/block_pass_fast_call_op2.phpt
M NEWS
M Zend/Optimizer/block_pass.c
Diff:
diff --git a/NEWS b/NEWS
index 214cc0a49321..20318bef27b4 100644
--- a/NEWS
+++ b/NEWS
@@ -85,6 +85,7 @@ PHP NEWS
. Fixed bug GH-23572 (Tracing JIT calls the wrong method for self::/parent::
static calls in trait methods shared by several classes). (jorgsowa,
mgoulart)
+ . Fix block pass dropping ZEND_FAST_CALL OP2 definition. (Mrmaxmeier)
- OpenSSL:
. Fixed bug GH-24784 (openssl_pkcs7_read() and openssl_cms_read() overwrite
diff --git a/Zend/Optimizer/block_pass.c b/Zend/Optimizer/block_pass.c
index 6f67fb0e0a78..e225634fec4c 100644
--- a/Zend/Optimizer/block_pass.c
+++ b/Zend/Optimizer/block_pass.c
@@ -352,6 +352,18 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array
*op_array
}
break;
+ case ZEND_FAST_CALL:
+ if (opline->op2_type & (IS_TMP_VAR|IS_VAR)) {
+ /* OP2 holds the pending return value. A TMP normally has a single
+ * consumer, but FAST_CALL reads does not consume it:
+ * the RETURN behind it is the consumer, and
+ * zend_dispatch_try_catch_finally_helper() destroys the value
+ * through OP2 if the finally block throws. Propagating the source
+ * into the RETURN therefore must not remove it. */
+ Tsource[VAR_NUM(opline->op2.var)] = NULL;
+ }
+ break;
+
case ZEND_SWITCH_LONG:
case ZEND_SWITCH_STRING:
case ZEND_MATCH:
diff --git a/ext/opcache/tests/opt/block_pass_fast_call_op2.phpt
b/ext/opcache/tests/opt/block_pass_fast_call_op2.phpt
new file mode 100644
index 000000000000..a3222bcf4636
--- /dev/null
+++ b/ext/opcache/tests/opt/block_pass_fast_call_op2.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Block pass must not remove the source of the ZEND_FAST_CALL OP2 return value
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+--FILE--
+<?php
+function test_scalar() {
+ $x = 1;
+ try {
+ try {
+ return true ? 1.5 : 2.5;
+ } finally {
+ undef_fn();
+ }
+ } catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+ }
+ return "fallback";
+}
+
+function test_refcounted() {
+ $x = 1;
+ try {
+ try {
+ return true ? "returned" : "other";
+ } finally {
+ undef_fn();
+ }
+ } catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+ }
+ return "fallback";
+}
+
+var_dump(test_scalar());
+var_dump(test_refcounted());
+?>
+--EXPECT--
+Error: Call to undefined function undef_fn()
+string(8) "fallback"
+Error: Call to undefined function undef_fn()
+string(8) "fallback"