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

From: Date: Sun, 25 Oct 2026 22:08:33 +0000
Subject: [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142729@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-25T23:07:58+01:00 Commit: https://github.com/php/php-src/commit/d98dc49a9a5949d5bc6ead987b5d285403b233bd Raw diff: https://github.com/php/php-src/commit/d98dc49a9a5949d5bc6ead987b5d285403b233bd.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: 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 b4cbb913c925..b53e372d033c 100644 --- a/NEWS +++ b/NEWS @@ -100,6 +100,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: . Fixed invalid ATTR_ORACLE_NULLS values being accepted and truncated. diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index f5e0bcfbcf59..9aeb44617135 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -5169,19 +5169,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) { @@ -5199,6 +5186,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"

« previous php.cvs (#142729) next »