[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Wed, 28 Oct 2026 22:12:26 +0000
Subject: [php-src] master: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142899@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-28T23:11:50+01:00 Commit: https://github.com/php/php-src/commit/772ea8e97699a4510dc593d3e65ace96a16447fd Raw diff: https://github.com/php/php-src/commit/772ea8e97699a4510dc593d3e65ace96a16447fd.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: 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 c5881da0fdd5..6e03095f6fc6 100644 --- a/NEWS +++ b/NEWS @@ -157,6 +157,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 ec98d814ed45..88526d4029cc 100644 --- a/Zend/Optimizer/block_pass.c +++ b/Zend/Optimizer/block_pass.c @@ -400,6 +400,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"

« previous php.cvs (#142899) next »