Skip to content

Commit 4227fdd

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix memory leak
2 parents 60f149f + cc465ba commit 4227fdd

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4928,6 +4928,10 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
49284928
} else {
49294929
ZEND_UNREACHABLE();
49304930
}
4931+
if (op1_addr == res_addr && (op2_info & MAY_BE_RCN)) {
4932+
/* compound assignment may decrement "op2" refcount */
4933+
op2_info |= MAY_BE_RC1;
4934+
}
49314935
| FREE_OP op1_type, op1, op1_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
49324936
| FREE_OP op2_type, op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
49334937
if (may_throw) {

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5423,6 +5423,10 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
54235423
|.if not(X64)
54245424
| add r4, 12
54255425
|.endif
5426+
if (op1_addr == res_addr && (op2_info & MAY_BE_RCN)) {
5427+
/* compound assignment may decrement "op2" refcount */
5428+
op2_info |= MAY_BE_RC1;
5429+
}
54265430
| FREE_OP op1_type, op1, op1_info, 0, NULL
54275431
| FREE_OP op2_type, op2, op2_info, 0, NULL
54285432
if (may_throw) {

ext/opcache/tests/jit/and_002.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
JIT BW_AND: 002 (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+
--FILE--
9+
<?php
10+
function t($a) {
11+
for($i = 0; $i < 2; $i++)
12+
$a &= $a = $a;
13+
}
14+
t("");
15+
?>
16+
DONE
17+
--EXPECTF--
18+
DONE

0 commit comments

Comments
 (0)