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

From: Date: Tue, 27 Oct 2026 21:34:35 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142858@lists.php.net to get a copy of this message
Author: Jorg Sowa (jorgsowa) Date: 2026-10-27T22:33:02+01:00 Commit: https://github.com/php/php-src/commit/c647ee5736fa57249154dcbe2a924cffb14a7596 Raw diff: https://github.com/php/php-src/commit/c647ee5736fa57249154dcbe2a924cffb14a7596.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: Fix JIT SWITCH_STRING type checks on referenced operand Changed paths: A ext/opcache/tests/jit/switch_002.phpt A ext/opcache/tests/jit/switch_003.phpt M NEWS M ext/opcache/jit/zend_jit_ir.c Diff: diff --git a/NEWS b/NEWS index 245d0c9538d9..0a4133df3c4a 100644 --- a/NEWS +++ b/NEWS @@ -142,6 +142,8 @@ PHP NEWS . Fixed bug GH-24675 (function with >~1.7 MB of machine code corrupts JIT buffer accounting). (ndossche) . Call orig_post_shutdown_cb(). (ndossche) + . Fixed JIT segfault on switch over a string reference holding a + non-string value. (jorgsowa) - PDO: . Fixed invalid ATTR_ORACLE_NULLS values being accepted and truncated. diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index ad67ca594884..7400ea70a71f 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -16500,7 +16500,7 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_ if (fallback_label) { jit_guard_Z_TYPE(jit, op1_addr, IS_REFERENCE, fallback_label); } else { - ir_ref if_ref = jit_if_Z_TYPE(jit, op1_addr, IS_STRING); + ir_ref if_ref = jit_if_Z_TYPE(jit, op1_addr, IS_REFERENCE); ir_IF_FALSE_cold(if_ref); ir_refs_add(slow_inputs, ir_END()); ir_IF_TRUE(if_ref); @@ -16510,7 +16510,7 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_ op1_addr = ZEND_ADDR_REF_ZVAL(ref2); if (fallback_label) { - jit_guard_Z_TYPE(jit, op1_addr, IS_LONG, fallback_label); + jit_guard_Z_TYPE(jit, op1_addr, IS_STRING, fallback_label); } else { if_string = jit_if_Z_TYPE(jit, op1_addr, IS_STRING); ir_IF_FALSE_cold(if_string); diff --git a/ext/opcache/tests/jit/switch_002.phpt b/ext/opcache/tests/jit/switch_002.phpt new file mode 100644 index 000000000000..580a1134c22e --- /dev/null +++ b/ext/opcache/tests/jit/switch_002.phpt @@ -0,0 +1,27 @@ +--TEST-- +JIT SWITCH_STRING on a reference holding a non-string value +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit=tracing +opcache.jit_hot_loop=1 +--EXTENSIONS-- +opcache +--FILE-- +<?php +function test($a) { + $n = 0; + foreach ($a as &$x) { + switch ($x) { + case "a": case "b": $n++; break; + } + } + return $n; +} +var_dump(test(["a"])); +var_dump(test([1])); +?> +--EXPECT-- +int(1) +int(0) diff --git a/ext/opcache/tests/jit/switch_003.phpt b/ext/opcache/tests/jit/switch_003.phpt new file mode 100644 index 000000000000..2a33f6dac457 --- /dev/null +++ b/ext/opcache/tests/jit/switch_003.phpt @@ -0,0 +1,26 @@ +--TEST-- +JIT SWITCH_STRING on a reference (function JIT) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit=function +--EXTENSIONS-- +opcache +--FILE-- +<?php +function test($a) { + $n = 0; + foreach ($a as &$x) { + switch ($x) { + case "a": case "b": $n++; break; + } + } + return $n; +} +var_dump(test(["a", "b", "c"])); +var_dump(test([1])); +?> +--EXPECT-- +int(2) +int(0)

« previous php.cvs (#142858) next »