Skip to content

Commit 683c988

Browse files
committed
Fixed bug #80194
We should strip NOPs from unreachable_free blocks as well, to make sure that the free really is the first op.
1 parent 9dddfbe commit 683c988

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ PHP NEWS
2929
- OPcache:
3030
. Fixed bug #80083 (Optimizer pass 6 removes variables used for ibm_db2 data
3131
binding). (Nikita)
32+
. Fixed bug #80194 (Assertion failure during block assembly of unreachable
33+
free with leading nop). (Nikita)
3234

3335
- PCRE:
3436
. Updated to PCRE 10.35. (cmb)

Zend/tests/bug80194.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #80194: Assertion failure during block assembly of unreachable free with leading nop
3+
--FILE--
4+
<?php
5+
6+
function test($x) {
7+
switch ($x->y) {
8+
default:
9+
throw new Exception;
10+
case 'foobar':
11+
return new stdClass();
12+
break;
13+
}
14+
}
15+
16+
$x = (object)['y' => 'foobar'];
17+
var_dump(test($x));
18+
19+
?>
20+
--EXPECT--
21+
object(stdClass)#2 (0) {
22+
}

ext/opcache/Optimizer/block_pass.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ void zend_optimize_cfg(zend_op_array *op_array, zend_optimizer_ctx *ctx)
19411941

19421942
/* Eliminate NOPs */
19431943
for (b = blocks; b < end; b++) {
1944-
if (b->flags & ZEND_BB_REACHABLE) {
1944+
if (b->flags & (ZEND_BB_REACHABLE|ZEND_BB_UNREACHABLE_FREE)) {
19451945
strip_nops(op_array, b);
19461946
}
19471947
}

0 commit comments

Comments
 (0)