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

From: Date: Tue, 24 Nov 2026 15:59:30 +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-144118@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Date: 2026-11-24T16:59:04+01:00 Commit: https://github.com/php/php-src/commit/c8d283693c937a7e79954b9df639f0a65d81a49d Raw diff: https://github.com/php/php-src/commit/c8d283693c937a7e79954b9df639f0a65d81a49d.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: Fix tracing JIT taking the wrong branch after a VM interrupt (#25636) Changed paths: A ext/opcache/tests/jit/trace_vm_interrupt_jmp_001.phpt M NEWS M ext/opcache/jit/zend_jit_ir.c Diff: diff --git a/NEWS b/NEWS index f190689eff41..adf4e20aea84 100644 --- a/NEWS +++ b/NEWS @@ -134,6 +134,8 @@ PHP NEWS order, or when the VM does not, on non-array containers. (Jorg Sowa) . Fixed bug GH-25449 (Element of a by-reference function result passed as an argument arrives as null). (Ilia Alshanetsky) + . Fixed tracing JIT taking the wrong branch after a VM interrupt. + (Brian Marks) - OpenSSL: . Fixed bug GH-25172 (TLS session reuse shares request-lifetime callback diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 505cc044b4a4..6990466a5957 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -17297,6 +17297,13 @@ static int zend_jit_trace_handler(zend_jit_ctx *jit, const zend_op_array *op_arr jit_STORE_IP(jit, ir_AND_A(ref, ir_CONST_ADDR(~ZEND_VM_ENTER_BIT))); } else { + /* A handler that jumps checks for interrupts. Once the interrupt + * function has run, it returns the next opline with + * ZEND_VM_ENTER_BIT set, which would fail the opline guard below + * and exit to the wrong branch. */ + if (zend_interrupt_function) { + ref = ir_AND_A(ref, ir_CONST_ADDR(~ZEND_VM_ENTER_BIT)); + } jit_STORE_IP(jit, ref); } } diff --git a/ext/opcache/tests/jit/trace_vm_interrupt_jmp_001.phpt b/ext/opcache/tests/jit/trace_vm_interrupt_jmp_001.phpt new file mode 100644 index 000000000000..0cd513b95ba1 --- /dev/null +++ b/ext/opcache/tests/jit/trace_vm_interrupt_jmp_001.phpt @@ -0,0 +1,47 @@ +--TEST-- +Tracing JIT: a jumping handler must not take the other branch after a VM interrupt +--DESCRIPTION-- +The object comparison raises an interrupt, and the observer INI setting +installs an interrupt callback. The tracing JIT runs COALESCE through its VM +handler. Taking the jump, the handler checks for interrupts and runs the +callback, then returns the jump target with ZEND_VM_ENTER_BIT set. Without +clearing that bit, the opline guard after the handler fails and the trace +exits to the fall-through branch, so ?? returns its default even though +the key exists. + +This fails on the CALL and TAILCALL VMs only; the HYBRID VM doesn't tag the +returned opline. +--EXTENSIONS-- +opcache +zend_test +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit=tracing +opcache.jit_buffer_size=64M +opcache.jit_hot_func=1 +opcache.jit_hot_loop=1 +opcache.jit_hot_return=1 +opcache.jit_hot_side_exit=1 +zend_test.observer.set_vm_interrupt_on_begin=1 +--FILE-- +<?php +function get(VmInterruptComparable $left, VmInterruptComparable $right, array $arr) { + // Raise an interrupt without an internal call that would handle it immediately. + $result = $left == $right; + return $arr['x'] ?? 'MISSING'; +} + +$left = new VmInterruptComparable(1); +$right = new VmInterruptComparable(2); +for ($i = 0; $i < 5; $i++) { + var_dump(get($left, $right, ['x' => $i])); +} +?> +--EXPECT-- +int(0) +int(1) +int(2) +int(3) +int(4)

« previous php.cvs (#144118) next »