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

From: Date: Tue, 29 Sep 2026 17:28:44 +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-141710@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-09-29T19:28:29+02:00 Commit: https://github.com/php/php-src/commit/f8324d20886a854059542f0d95d866aa9a4e01c1 Raw diff: https://github.com/php/php-src/commit/f8324d20886a854059542f0d95d866aa9a4e01c1.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: NEWS Fix property hook escape analysis causing misoptimization Fix __isset escape analysis causing misoptimization Changed paths: A ext/opcache/tests/opt/dce_016.phpt A ext/opcache/tests/opt/dce_017.phpt M NEWS M Zend/Optimizer/escape_analysis.c Diff: diff --git a/NEWS b/NEWS index b4ebac826d7f..d700a7be0de0 100644 --- a/NEWS +++ b/NEWS @@ -31,7 +31,8 @@ PHP NEWS . Fix zend_analyze_calls() call_stack buffer overrun. (Mrmaxmeier) . 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) + . Fix multiple incorrect DCE due to unsound escape analysis. (ndossche, + arnaud-lb) - OpenSSL: . Fixed stream_socket_enable_crypto() leaving the socket non-blocking diff --git a/Zend/Optimizer/escape_analysis.c b/Zend/Optimizer/escape_analysis.c index ca1cb6c1fdee..59e0cea05a79 100644 --- a/Zend/Optimizer/escape_analysis.c +++ b/Zend/Optimizer/escape_analysis.c @@ -170,6 +170,8 @@ static bool is_allocation_def(const zend_op_array *op_array, const zend_ssa *ssa && !ce->destructor && !ce->__get && !ce->__set + && !ce->__isset + && !ce->num_hooked_props && !(ce->ce_flags & forbidden_flags) && (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { return true; @@ -239,6 +241,8 @@ static bool is_local_def(const zend_op_array *op_array, const zend_ssa *ssa, int && !ce->destructor && !ce->__get && !ce->__set + && !ce->__isset + && !ce->num_hooked_props && !ce->parent) { return true; } diff --git a/ext/opcache/tests/opt/dce_016.phpt b/ext/opcache/tests/opt/dce_016.phpt new file mode 100644 index 000000000000..2185a4abfee7 --- /dev/null +++ b/ext/opcache/tests/opt/dce_016.phpt @@ -0,0 +1,50 @@ +--TEST-- +DCE must not remove assignments to properties of an object escaping through __isset +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.file_update_protection=0 +--EXTENSIONS-- +opcache +--FILE-- +<?php + +class C { + public $x = 0; + function __isset($n) { + global $g; + $g = $this; + return true; + } +} + +function f() { + $o = new C; + isset($o->foo); + $o->x = 42; +} + +f(); +var_dump($g->x); + +#[AllowDynamicProperties] +class F { + function __isset($n) { + $this->x = 2; + return true; + } +} + +function i() { + $o = new F; + $o->x = 1; + isset($o->foo); + var_dump($o->x); +} +i(); + +?> +--EXPECT-- +int(42) +int(2) diff --git a/ext/opcache/tests/opt/dce_017.phpt b/ext/opcache/tests/opt/dce_017.phpt new file mode 100644 index 000000000000..0cf8ad9bf366 --- /dev/null +++ b/ext/opcache/tests/opt/dce_017.phpt @@ -0,0 +1,55 @@ +--TEST-- +DCE must not remove assignments to properties of an object escaping through a property hook +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.file_update_protection=0 +--EXTENSIONS-- +opcache +--FILE-- +<?php + +class D { + public $x = 0; + public $h { + get { + global $g; + $g = $this; + return 1; + } + } +} + +function g() { + $o = new D; + $o->h; + $o->x = 42; +} + +g(); +var_dump($g->x); + +class E { + public $x = 0; + public $h { + set { + global $g; + $g = $this; + } + } +} + +function h() { + $o = new E; + $o->h = 1; + $o->x = 42; +} + +h(); +var_dump($g->x); + +?> +--EXPECT-- +int(42) +int(42)

« previous php.cvs (#141710) next »