Skip to content

Commit 4767c06

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix phpGH-16770: Tracing JIT type mismatch when returning UNDEF
2 parents ec3de14 + 0bf74bf commit 4767c06

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

+3
Original file line numberDiff line numberDiff line change
@@ -5527,6 +5527,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
55275527
res_type = Z_TYPE_P(RT_CONSTANT(opline, opline->op1));
55285528
} else if (op1_type != IS_UNKNOWN) {
55295529
res_type = op1_type;
5530+
if (res_type == IS_UNDEF) {
5531+
res_type = IS_NULL;
5532+
}
55305533
}
55315534
if (op_array->type == ZEND_EVAL_CODE
55325535
// TODO: support for top-level code

ext/opcache/tests/jit/gh16770.phpt

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
GH-16770 (Tracing JIT type mismatch when returning UNDEF)
3+
--INI--
4+
opcache.jit=1254
5+
opcache.jit_hot_loop=1
6+
opcache.jit_buffer_size=32M
7+
--EXTENSIONS--
8+
opcache
9+
--FILE--
10+
<?php
11+
function ret_undef($k) {
12+
return $undefined;
13+
}
14+
for ($i = 0; $i < 10; $i++) {
15+
$output = ret_undef($i);
16+
}
17+
var_dump($output);
18+
?>
19+
--EXPECTF--
20+
Warning: Undefined variable $undefined in %s on line %d
21+
22+
Warning: Undefined variable $undefined in %s on line %d
23+
24+
Warning: Undefined variable $undefined in %s on line %d
25+
26+
Warning: Undefined variable $undefined in %s on line %d
27+
28+
Warning: Undefined variable $undefined in %s on line %d
29+
30+
Warning: Undefined variable $undefined in %s on line %d
31+
32+
Warning: Undefined variable $undefined in %s on line %d
33+
34+
Warning: Undefined variable $undefined in %s on line %d
35+
36+
Warning: Undefined variable $undefined in %s on line %d
37+
38+
Warning: Undefined variable $undefined in %s on line %d
39+
NULL

0 commit comments

Comments
 (0)