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
5 changes: 4 additions & 1 deletion ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6582,7 +6582,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
}
}
}
if (ssa->var_info[ssa_op->result_def].type & MAY_BE_INDIRECT) {
if ((ssa->var_info[ssa_op->result_def].type & MAY_BE_INDIRECT)
|| opline->opcode == ZEND_FETCH_OBJ_R
|| opline->opcode == ZEND_FETCH_OBJ_FUNC_ARG
|| opline->opcode == ZEND_FETCH_OBJ_IS) {
RESET_STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var));
}
if (type != IS_UNKNOWN) {
Expand Down
48 changes: 48 additions & 0 deletions ext/opcache/tests/jit/gh25480.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--TEST--
GH-25480: Tracing JIT does not reuse stale FETCH_DIM_IS result
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit=tracing
opcache.jit_hot_loop=1
opcache.jit_buffer_size=16M
--EXTENSIONS--
opcache
--FILE--
<?php
class Row {
public function __get(string $name): int {
return 1;
}
}

function take(?array $a): bool {
return $a === [] || $a === ['present'];
}

function run(array $rows, array $map, ?object $none): int {
$bad = 0;
foreach ($rows as $id => $row) {
if ($none?->id == $id) {}
$x = $row->a && $row->b;
try {
if (!take($map[$id] ?? [])) {
$bad++;
}
} catch (TypeError $e) {
$bad++;
}
}
return $bad;
}

$rows = array_fill(0, 100, new Row());
$bad = 0;
for ($i = 0; $i < 10; $i++) {
$bad += run($rows, [0 => ['present']], null);
}
echo "Bad values: $bad\n";
?>
--EXPECT--
Bad values: 0
Loading