Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ PHP NEWS
empty array element. (jorgsowa)
. Fixed bug GH-24396 (Assertion failure in zend_jit_def_reg() "reg forwarding"
with chained Pi nodes). (ndossche)
. Fixed bug GH-24634 (Tracing JIT reads a stale stack slot at a side exit).
(Lazizbek Ergashev)

- PDO:
. Fixed invalid ATTR_ORACLE_NULLS values being accepted and truncated.
Expand Down
11 changes: 6 additions & 5 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@ static bool zend_ssa_is_last_use(const zend_op_array *op_array, const zend_ssa *
}

next_use = zend_ssa_next_use(ssa->ops, var, use);
if (next_use < 0) {
return 1;
} else if (zend_ssa_is_no_val_use(op_array->opcodes + next_use, ssa->ops + next_use, var)) {
return 1;
while (next_use >= 0) {
if (!zend_ssa_is_no_val_use(op_array->opcodes + next_use, ssa->ops + next_use, var)) {
return 0;
}
next_use = zend_ssa_next_use(ssa->ops, var, next_use);
}
return 0;
return 1;
}

static int zend_jit_is_constant_cmp_long_long(const zend_op *opline,
Expand Down
44 changes: 44 additions & 0 deletions ext/opcache/tests/jit/gh24634.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--TEST--
GH-24634 (Tracing JIT reads a stale stack slot at a side exit)
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=64M
opcache.jit=tracing
opcache.jit_hot_loop=1
opcache.jit_hot_func=1
opcache.jit_hot_return=1
opcache.jit_hot_side_exit=1
--FILE--
<?php
function f(int $x) {
$e = $x & 3;
$m = $x & 4;
if ($e === 0) {
if ($m === 0) {
$r = 0;
} else {
$e = 100;
while ($m < 16) {
$m <<= 1;
$e--;
}
$r = $e;
}
} else {
$r = $e + 10;
}
return $r;
}

$out = [];
for ($i = 0; $i < 8; $i++) {
$out[] = f($i);
}
echo implode(" ", $out), "\n";
?>
--EXPECT--
0 11 12 13 98 11 12 13
Loading