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

From: Date: Sat, 31 Oct 2026 23:12:13 +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-143091@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-11-01T00:11:56+01:00 Commit: https://github.com/php/php-src/commit/99b8c6afed23434ce656705c4fc7f31970750b5c Raw diff: https://github.com/php/php-src/commit/99b8c6afed23434ce656705c4fc7f31970750b5c.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: Fix GH-24988: Incorrect opcode range check causes bugs with exceptions in function JIT Changed paths: A ext/opcache/tests/jit/gh24988.phpt M NEWS M ext/opcache/jit/zend_jit.c Diff: diff --git a/NEWS b/NEWS index a22b52bafd0d..a00a3aedefc1 100644 --- a/NEWS +++ b/NEWS @@ -132,6 +132,8 @@ PHP NEWS (ndossche) . Fixed preloaded functions not JIT-compiled again after OPcache restart. (Jorg Sowa) + . Fixed bug GH-24988 (Incorrect opcode range check causes bugs with exceptions in + function JIT). (ndossche, Jorg Sowa) - OpenSSL: . Fixed build with OpenSSL 4.1. (Weilin Du) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index fbfde39863ac..28e6f1e8217e 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -1289,7 +1289,7 @@ static void zend_jit_allocate_registers(zend_jit_ctx *ctx, const zend_op_array * if (range->start > op_num) { /* further blocks will not be relevant... */ break; - } else if (op_num < range->end && var_num == (range->var & ~ZEND_LIVE_MASK)) { + } else if (op_num < range->end && EX_NUM_TO_VAR(var_num) == (range->var & ~ZEND_LIVE_MASK)) { /* check if opcodes in range may throw */ do { if (zend_may_throw(op_array->opcodes + op_num, ssa->ops + op_num, op_array, ssa)) { diff --git a/ext/opcache/tests/jit/gh24988.phpt b/ext/opcache/tests/jit/gh24988.phpt new file mode 100644 index 000000000000..f8cd56e5bec1 --- /dev/null +++ b/ext/opcache/tests/jit/gh24988.phpt @@ -0,0 +1,47 @@ +--TEST-- +GH-24988 (JIT: crash in cleanup_live_vars when % by zero throws mid-expression) +--CREDITS-- +waroad +jorgsowa +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit_buffer_size=64M +opcache.jit=function +opcache.optimization_level=0 +--EXTENSIONS-- +opcache +--FILE-- +<?php + +class D { + function self() { return $this; } + function __destruct() { echo "dtor\n"; } +} + +// Leaves a stale object in the frame slot deep() uses for its first temporary +function pollute($a, $b, $c) { + return $a->self()->self(); +} + +function deep(int $a, int $b, int $c) { + $a &= 255; + return ($a + 1) - ($b + $b + (($a + 1) % ($b % $c))); +} + +$o = new D; +var_dump(deep(15, 3, 7)); +pollute($o, 1, 2); +try { + deep(15, 3, 0); +} catch (DivisionByZeroError $e) { + echo $e->getMessage(), "\n"; +} +echo "end\n"; + +?> +--EXPECT-- +int(9) +Modulo by zero +end +dtor

« previous php.cvs (#143091) next »