Skip to content

Commit 0bf74bf

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

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ PHP NEWS
1919
- Hash:
2020
. Fixed GH-16711: Segfault in mhash(). (Girgias)
2121

22+
- Opcache:
23+
. Fixed bug GH-16770 (Tracing JIT type mismatch when returning UNDEF).
24+
(nielsdos, Dmitry)
25+
2226
- OpenSSL:
2327
. Prevent unexpected array entry conversion when reading key. (nielsdos)
2428
. Fix various memory leaks related to openssl exports. (nielsdos)

ext/opcache/jit/zend_jit_trace.c

+3
Original file line numberDiff line numberDiff line change
@@ -5408,6 +5408,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
54085408
res_type = Z_TYPE_P(RT_CONSTANT(opline, opline->op1));
54095409
} else if (op1_type != IS_UNKNOWN) {
54105410
res_type = op1_type;
5411+
if (res_type == IS_UNDEF) {
5412+
res_type = IS_NULL;
5413+
}
54115414
}
54125415
if (op_array->type == ZEND_EVAL_CODE
54135416
// 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)