From d3812ca41b8ff40cc2d38fb4d2a79ae1902761cb Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 19 Oct 2020 15:13:40 +0200 Subject: [PATCH] Fixed bug #80255 This was a copy&paste mistake, target_block was used where follow_block was intended. Also update copy&paste mistakes in the comments. --- NEWS | 3 +++ Zend/tests/bug80255.phpt | 24 ++++++++++++++++++++++++ ext/opcache/Optimizer/block_pass.c | 8 ++++---- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 Zend/tests/bug80255.phpt diff --git a/NEWS b/NEWS index 736ae5e0a3..54948f1134 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ PHP NEWS - IMAP: . Fixed bug #80239 (imap_rfc822_write_address() leaks memory). (cmb) +- Opcache: + . Fixed bug #80255 (Opcache bug (bad condition result) in 8.0.0rc1). (Nikita) + 15 Oct 2020, PHP 8.0.0RC2 - Core: diff --git a/Zend/tests/bug80255.phpt b/Zend/tests/bug80255.phpt new file mode 100644 index 0000000000..d3fc6b7abe --- /dev/null +++ b/Zend/tests/bug80255.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #80255: Opcache bug (bad condition result) in 8.0.0rc1 +--FILE-- + +--EXPECT-- +foo +bar +baz diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index 5b6870ed0a..bad814ed6e 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -1516,16 +1516,16 @@ optimize_jmpznz: target = op_array->opcodes + follow_block->start; if (target->opcode == ZEND_JMP) { - /* JMPZNZ(X, L1, L2), L1: JMP(L3) -> JMPZNZ(X, L3, L2) */ + /* JMPZNZ(X, L1, L2), L2: JMP(L3) -> JMPZNZ(X, L1, L3) */ next = follow_block->successors[0]; } else if (target->opcode == ZEND_JMPNZ && SAME_VAR(target->op1, last_op->op1)) { - /* JMPZNZ(X, L1, L2), L1: X = JMPNZ(X, L3) -> JMPZNZ(X, L1+1, L2) */ + /* JMPZNZ(X, L1, L2), L2: X = JMPNZ(X, L3) -> JMPZNZ(X, L1, L3) */ next = follow_block->successors[0]; } else if ((target->opcode == ZEND_JMPZ || target->opcode == ZEND_JMPZNZ) && SAME_VAR(target->op1, last_op->op1)) { - /* JMPZNZ(X, L1, L2), L1: JMPZ(X, L3) -> JMPZNZ(X, L3, L2) */ - next = target_block->successors[1]; + /* JMPZNZ(X, L1, L2), L2: JMPZ(X, L3) -> JMPZNZ(X, L1, L2+1) */ + next = follow_block->successors[1]; } else { break; } -- 2.40.0