Skip to content

Commit 9b7e086

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17654: Multiple classes using same trait causes function JIT crash
2 parents 4e6a3ce + 6d6380c commit 9b7e086

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10053,9 +10053,9 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
1005310053
func = call_info->callee_func;
1005410054
}
1005510055
if ((op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)
10056-
&& JIT_G(current_frame)
10057-
&& JIT_G(current_frame)->call
10058-
&& !JIT_G(current_frame)->call->func) {
10056+
&& (!JIT_G(current_frame)
10057+
|| !JIT_G(current_frame)->call
10058+
|| !JIT_G(current_frame)->call->func)) {
1005910059
call_info = NULL; func = NULL; /* megamorphic call from trait */
1006010060
}
1006110061
}

ext/opcache/tests/jit/gh17654.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
GH-17654 (Multiple classes using same trait causes function JIT crash)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.jit=1214
7+
opcache.jit_buffer_size=16M
8+
--FILE--
9+
<?php
10+
trait TestTrait {
11+
public function addUnit(string $x) {
12+
self::addRawUnit($this, $x);
13+
}
14+
15+
public function addRawUnit(self $data, string $x) {
16+
var_dump($x);
17+
}
18+
}
19+
20+
class Test {
21+
use TestTrait;
22+
}
23+
24+
class Test2 {
25+
use TestTrait;
26+
}
27+
28+
function main()
29+
{
30+
(new Test2)->addUnit("test2");
31+
(new Test)->addUnit("test");
32+
}
33+
34+
main();
35+
?>
36+
--EXPECT--
37+
string(5) "test2"
38+
string(4) "test"

0 commit comments

Comments
 (0)