Skip to content

Commit

Permalink
Merge branch 'PHP-8.4'
Browse files Browse the repository at this point in the history
* PHP-8.4:
  Fix GH-16770: Tracing JIT type mismatch when returning UNDEF
  • Loading branch information
nielsdos committed Nov 14, 2024
2 parents f0b4847 + 4767c06 commit 3f4bcd8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5560,6 +5560,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
res_type = Z_TYPE_P(RT_CONSTANT(opline, opline->op1));
} else if (op1_type != IS_UNKNOWN) {
res_type = op1_type;
if (res_type == IS_UNDEF) {
res_type = IS_NULL;
}
}
if (op_array->type == ZEND_EVAL_CODE
// TODO: support for top-level code
Expand Down
39 changes: 39 additions & 0 deletions ext/opcache/tests/jit/gh16770.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
GH-16770 (Tracing JIT type mismatch when returning UNDEF)
--INI--
opcache.jit=1254
opcache.jit_hot_loop=1
opcache.jit_buffer_size=32M
--EXTENSIONS--
opcache
--FILE--
<?php
function ret_undef($k) {
return $undefined;
}
for ($i = 0; $i < 10; $i++) {
$output = ret_undef($i);
}
var_dump($output);
?>
--EXPECTF--
Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d

Warning: Undefined variable $undefined in %s on line %d
NULL

0 comments on commit 3f4bcd8

Please sign in to comment.