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

From: Date: Wed, 28 Oct 2026 22:25:04 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142909@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-28T23:24:55+01:00 Commit: https://github.com/php/php-src/commit/17cfa007d5daf760cbcc76916fb52d673c9e530f Raw diff: https://github.com/php/php-src/commit/17cfa007d5daf760cbcc76916fb52d673c9e530f.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix GH-23626: OPcache: orphaned temporaries cause leaks and assertions Changed paths: A ext/opcache/tests/gh23626.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 7bbf111985f5..5d69ebb65568 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7349,10 +7349,9 @@ static void zend_compile_match(znode *result, zend_ast *ast) if (opline->op1_type == IS_CONST) { Z_TRY_ADDREF_P(CT_CONSTANT(opline->op1)); } - if (arms->children == 0) { - /* Mark this as an "expression throw" for opcache. */ - opline->extended_value = ZEND_THROW_IS_EXPR; - } + /* Mark this as an "expression throw" for opcache. + * Even if there are arms, they may become unreachable after optimization, which loses live ranges. */ + opline->extended_value = ZEND_THROW_IS_EXPR; } for (uint32_t i = 0; i < arms->children; ++i) { diff --git a/ext/opcache/tests/gh23626.phpt b/ext/opcache/tests/gh23626.phpt new file mode 100644 index 000000000000..67e20da9def5 --- /dev/null +++ b/ext/opcache/tests/gh23626.phpt @@ -0,0 +1,59 @@ +--TEST-- +GH-23626: OPcache: orphaned temporaries cause leaks and assertions +--CREDITS-- +Mrmaxmeier +--EXTENSIONS-- +opcache +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--FILE-- +<?php +class D { + public function __construct(public string $name) {} + public function __clone() { $this->name .= '-clone'; } + public function __destruct() { echo "destruct {$this->name}\n"; } +} + +function test_assert($u) { + (function () use ($u) {}) ** match (1) { 2 => 3 }; +} + +function one($o) { + (clone $o) ** match (1) { 2 => 3 }; +} + +function two($a, $b) { + (clone $a) ** ((clone $b) ** match (1) { 2 => 3 }); +} + +function rope($o) { + return "x{$o->name}y" . match (1) { 2 => 3 }; +} + +$a = new D('a'); +$b = new D('b'); + +foreach (['test_assert' => [1], 'one' => [$a], 'two' => [$a, $b], 'rope' => [$a]] as $fn => $args) { + try { + $fn(...$args); + } catch (\UnhandledMatchError $e) { + echo "$fn: ", $e->getMessage(), "\n"; + } +} + +unset($a, $b, $args, $e); +echo "done\n"; +?> +--EXPECT-- +test_assert: Unhandled match case 1 +destruct a-clone +one: Unhandled match case 1 +destruct a-clone +destruct b-clone +two: Unhandled match case 1 +rope: Unhandled match case 1 +destruct b +destruct a +done

« previous php.cvs (#142909) next »