Skip to content

Commit 6d6380c

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-17654: Multiple classes using same trait causes function JIT crash
2 parents 59ed637 + f88445b commit 6d6380c

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ PHP NEWS
1515
. Fixed bug GH-17609 (Typo in error message: Dom\NO_DEFAULT_NS instead of
1616
Dom\HTML_NO_DEFAULT_NS). (nielsdos)
1717

18+
- Opcache:
19+
. Fixed bug GH-17654 (Multiple classes using same trait causes function
20+
JIT crash). (nielsdos)
21+
1822
- PHPDBG:
1923
. Partially fixed bug GH-17387 (Trivial crash in phpdbg lexer). (nielsdos)
2024
. Fix memory leak in phpdbg calling registered function. (nielsdos)

ext/opcache/jit/zend_jit_ir.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9871,9 +9871,9 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
98719871
func = call_info->callee_func;
98729872
}
98739873
if ((op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)
9874-
&& JIT_G(current_frame)
9875-
&& JIT_G(current_frame)->call
9876-
&& !JIT_G(current_frame)->call->func) {
9874+
&& (!JIT_G(current_frame)
9875+
|| !JIT_G(current_frame)->call
9876+
|| !JIT_G(current_frame)->call->func)) {
98779877
call_info = NULL; func = NULL; /* megamorphic call from trait */
98789878
}
98799879
}

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)