Skip to content

Commit 8633893

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fix memory lek
2 parents 69bcd93 + 3aaf2f6 commit 8633893

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4570,7 +4570,10 @@ static int zend_jit_math_helper(dasm_State **Dst,
45704570
| FREE_OP op1_type, op1, op1_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
45714571
| FREE_OP op2_type, op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
45724572
if (may_throw) {
4573-
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
4573+
if (opline->opcode == ZEND_ASSIGN_DIM_OP && (opline->op2_type & (IS_VAR|IS_TMP_VAR))) {
4574+
| MEM_LOAD_64_ZTS ldr, TMP2, executor_globals, exception, TMP1
4575+
| cbnz TMP2, ->exception_handler_free_op2
4576+
} else if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
45744577
zend_jit_check_exception_undef_result(Dst, opline);
45754578
} else {
45764579
zend_jit_check_exception(Dst);

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4991,7 +4991,10 @@ static int zend_jit_math_helper(dasm_State **Dst,
49914991
| FREE_OP op1_type, op1, op1_info, 0, NULL
49924992
| FREE_OP op2_type, op2, op2_info, 0, NULL
49934993
if (may_throw) {
4994-
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
4994+
if (opline->opcode == ZEND_ASSIGN_DIM_OP && (opline->op2_type & (IS_VAR|IS_TMP_VAR))) {
4995+
| MEM_CMP_ZTS aword, executor_globals, exception, 0, r0
4996+
| jne ->exception_handler_free_op2
4997+
} else if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
49954998
zend_jit_check_exception_undef_result(Dst, opline);
49964999
} else {
49975000
zend_jit_check_exception(Dst);

ext/opcache/tests/jit/mul_009.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
JIT MUL: 009 memory leak
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--FILE--
10+
<?php
11+
$x[""][] = 1;
12+
$x[~"$y"] *= 1;
13+
?>
14+
--EXPECTF--
15+
Warning: Undefined variable $y in %smul_009.php on line 3
16+
17+
Fatal error: Uncaught TypeError: Unsupported operand types: array * int in %smul_009.php:3
18+
Stack trace:
19+
#0 {main}
20+
thrown in %smul_009.php on line 3

0 commit comments

Comments
 (0)