Skip to content

Fix GH-16770: Tracing JIT type mismatch when returning UNDEF #16784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
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 @@ -5404,6 +5404,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
Loading