summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-10-07 15:03:12 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-10-07 15:03:12 +0200
commit683c988493920e033f0c7f5455ebfc3825c38887 (patch)
treea9ce111a6920e85860e8234ef4a01c381edb9136
parent9dddfbe755e308d47e1c1c9349b778abed52cd3c (diff)
downloadphp-git-683c988493920e033f0c7f5455ebfc3825c38887.tar.gz
Fixed bug #80194
We should strip NOPs from unreachable_free blocks as well, to make sure that the free really is the first op.
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug80194.phpt22
-rw-r--r--ext/opcache/Optimizer/block_pass.c2
3 files changed, 25 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 85110a9f50..5907cc864f 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,8 @@ PHP NEWS
- OPcache:
. Fixed bug #80083 (Optimizer pass 6 removes variables used for ibm_db2 data
binding). (Nikita)
+ . Fixed bug #80194 (Assertion failure during block assembly of unreachable
+ free with leading nop). (Nikita)
- PCRE:
. Updated to PCRE 10.35. (cmb)
diff --git a/Zend/tests/bug80194.phpt b/Zend/tests/bug80194.phpt
new file mode 100644
index 0000000000..9a5cdcd718
--- /dev/null
+++ b/Zend/tests/bug80194.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #80194: Assertion failure during block assembly of unreachable free with leading nop
+--FILE--
+<?php
+
+function test($x) {
+ switch ($x->y) {
+ default:
+ throw new Exception;
+ case 'foobar':
+ return new stdClass();
+ break;
+ }
+}
+
+$x = (object)['y' => 'foobar'];
+var_dump(test($x));
+
+?>
+--EXPECT--
+object(stdClass)#2 (0) {
+}
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 17b89c4d53..22d4b5294e 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -1941,7 +1941,7 @@ void zend_optimize_cfg(zend_op_array *op_array, zend_optimizer_ctx *ctx)
/* Eliminate NOPs */
for (b = blocks; b < end; b++) {
- if (b->flags & ZEND_BB_REACHABLE) {
+ if (b->flags & (ZEND_BB_REACHABLE|ZEND_BB_UNREACHABLE_FREE)) {
strip_nops(op_array, b);
}
}