Skip to content

Commit 8026001

Browse files
committed
Fixed bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF)
1 parent 33e2aa4 commit 8026001

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #69566 (Conditional jump or move depends on uninitialised value
77
in extension trait). (jbboehr at gmail dot com)
88

9+
- Opcache
10+
. Fixed bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF).
11+
(Laruence, Dmitry)
12+
913
14 May 2015, PHP 5.5.25
1014

1115
- Core:

ext/opcache/Optimizer/block_pass.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,13 +1759,15 @@ static void zend_jmp_optimization(zend_code_block *block, zend_op_array *op_arra
17591759
}
17601760
} else if (block->op2_to == block->ext_to) {
17611761
/* both goto the same one - it's JMP */
1762-
/* JMPZNZ(?,L,L) -> JMP(L) */
1763-
last_op->opcode = ZEND_JMP;
1764-
SET_UNUSED(last_op->op1);
1765-
SET_UNUSED(last_op->op2);
1766-
block->op1_to = block->op2_to;
1767-
block->op2_to = NULL;
1768-
block->ext_to = NULL;
1762+
if (!(last_op->op1_type & (IS_VAR|IS_TMP_VAR))) {
1763+
/* JMPZNZ(?,L,L) -> JMP(L) */
1764+
last_op->opcode = ZEND_JMP;
1765+
SET_UNUSED(last_op->op1);
1766+
SET_UNUSED(last_op->op2);
1767+
block->op1_to = block->op2_to;
1768+
block->op2_to = NULL;
1769+
block->ext_to = NULL;
1770+
}
17691771
} else if (block->op2_to == next) {
17701772
/* jumping to next on Z - can follow to it and jump only on NZ */
17711773
/* JMPZNZ(X,L1,L2) L1: -> JMPNZ(X,L2) */

ext/opcache/tests/bug695449.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
$a = array(true);
12+
if($a[0] && false) {
13+
echo 'test';
14+
}
15+
echo "ok\n";
16+
?>
17+
--EXPECT--
18+
ok

0 commit comments

Comments
 (0)