[php-src] master: Merge branch 'PHP-8.6'

From: Date: Wed, 28 Oct 2026 22:12:29 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142902@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-28T23:12:19+01:00 Commit: https://github.com/php/php-src/commit/5dcd4f6f49ea26b276842af6fdc8ba389db39ef9 Raw diff: https://github.com/php/php-src/commit/5dcd4f6f49ea26b276842af6fdc8ba389db39ef9.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix block pass dropping ZEND_FAST_CALL OP2 definition Changed paths: A ext/opcache/tests/opt/block_pass_fast_call_op2.phpt M Zend/Optimizer/block_pass.c Diff: 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"

« previous php.cvs (#142902) next »