[php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
| From: | ndossche | Date: | Sun, 25 Oct 2026 22:08:33 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142730@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-10-25T23:08:15+01:00
Commit: https://github.com/php/php-src/commit/fadc1e5e7e7568dd1068e85c4fde410df389d643
Raw diff: https://github.com/php/php-src/commit/fadc1e5e7e7568dd1068e85c4fde410df389d643.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Tracing JIT: keep the SEND_VAL type guard after assigning to a reference
Changed paths:
A ext/opcache/tests/jit/gh24436.phpt
M NEWS
M ext/opcache/jit/zend_jit_trace.c
Diff:
diff --git a/NEWS b/NEWS
index d323a17a824e..140975629a81 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,8 @@ PHP NEWS
with chained Pi nodes). (ndossche)
. Fixed JIT treating an array as packed after a string key write turned it
into a hash. (jorgsowa)
+ . Fixed bug GH-24436 (Tracing JIT: keep the SEND_VAL type guard after
+ assigning to a reference). (waroad)
- PDO_PGSQL:
. Fixed bug GH-24461 (DISCARD ALL on persistent connection cleanup drops
diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c
index 96fa6068ce6d..1e8beb25c3f3 100644
--- a/ext/opcache/jit/zend_jit_trace.c
+++ b/ext/opcache/jit/zend_jit_trace.c
@@ -5186,19 +5186,6 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec
*trace_buffer,
&& ssa->vars[ssa_op->op1_def].alias == NO_ALIAS) {
ssa->var_info[ssa_op->op1_def].guarded_reference = 1;
}
- if (opline->result_type == IS_UNUSED) {
- res_addr = 0;
- } else {
- res_addr = RES_REG_ADDR();
- if (Z_MODE(res_addr) != IS_REG
- && zend_jit_trace_next_is_send_result(opline, p, frame)) {
- send_result = 1;
- res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_RX, (opline+1)->result.var);
- if (!zend_jit_reuse_ip(&ctx)) {
- goto jit_failure;
- }
- }
- }
op1_def_addr = op1_addr;
op1_def_info &= ~MAY_BE_REF;
} else if (op1_info & MAY_BE_REF) {
@@ -5216,6 +5203,9 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec
*trace_buffer,
res_addr = RES_REG_ADDR();
res_info = RES_INFO();
if (Z_MODE(res_addr) != IS_REG
+ /* assignment to typed reference may cause conversion,
+ * so SEND_VAL has to check the type of the result */
+ && !ref_addr
&& zend_jit_trace_next_is_send_result(opline, p, frame)) {
send_result = 1;
res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_RX, (opline+1)->result.var);
diff --git a/ext/opcache/tests/jit/gh24436.phpt b/ext/opcache/tests/jit/gh24436.phpt
new file mode 100644
index 000000000000..cc60764759c4
--- /dev/null
+++ b/ext/opcache/tests/jit/gh24436.phpt
@@ -0,0 +1,38 @@
+--TEST--
+GH-24436 (Tracing JIT: wrong value of assignment to typed reference passed as argument)
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=tracing
+--FILE--
+<?php
+class Box {
+ public $v = 1;
+ public float $f = 1;
+ public string $s = "";
+}
+
+function sink($x) {
+ return $x;
+}
+
+function work(&$x, $y) {
+ return sink($x = $y + 2);
+}
+
+$o = new Box;
+foreach (['v', 'v', 'v', 'f', 's'] as $p) {
+ var_dump(work($o->$p, 3));
+}
+var_dump($o->f, $o->s);
+?>
+--EXPECT--
+int(5)
+int(5)
+int(5)
+float(5)
+string(1) "5"
+float(5)
+string(1) "5"