Skip to content

Commit cc465ba

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix memory leak
2 parents 0ae9942 + 44b86ae commit cc465ba

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
@@ -4933,6 +4933,10 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
49334933
} else {
49344934
ZEND_UNREACHABLE();
49354935
}
4936+
if (op1_addr == res_addr && (op2_info & MAY_BE_RCN)) {
4937+
/* compound assignment may decrement "op2" refcount */
4938+
op2_info |= MAY_BE_RC1;
4939+
}
49364940
| FREE_OP op1_type, op1, op1_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
49374941
| FREE_OP op2_type, op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
49384942
if (may_throw) {

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5409,6 +5409,10 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
54095409
|.if not(X64)
54105410
| add r4, 12
54115411
|.endif
5412+
if (op1_addr == res_addr && (op2_info & MAY_BE_RCN)) {
5413+
/* compound assignment may decrement "op2" refcount */
5414+
op2_info |= MAY_BE_RC1;
5415+
}
54125416
| FREE_OP op1_type, op1, op1_info, 0, NULL
54135417
| FREE_OP op2_type, op2, op2_info, 0, NULL
54145418
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)