summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-02-16 20:27:13 +0100
committerNikita Popov <nikita.ppv@gmail.com>2018-02-16 20:30:03 +0100
commit372bf8a9231a58ef8d1d2f0d9b560167495e215e (patch)
treeaa1581814e992b46e99e357e4408b60c5e6e9ba3
parentda0ed5cdb13b7a6ca59c2c1653c6f6665aec81d2 (diff)
downloadphp-git-372bf8a9231a58ef8d1d2f0d9b560167495e215e.tar.gz
Fixed bug #75969
Move NOP stripping out of zend_optimize_block: NOP stripping may move instructions, which may invalidate a Tsource shared across an extended basic block.
-rw-r--r--NEWS4
-rw-r--r--ext/opcache/Optimizer/block_pass.c9
-rw-r--r--ext/opcache/tests/bug75969.phpt24
3 files changed, 35 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index d79f219612..6e7e7e8840 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,10 @@ PHP NEWS
- ODBC:
. Fixed bug #73725 (Unable to retrieve value of varchar(max) type). (Anatol)
+- Opcache:
+ . Fixed bug #75969 (Assertion failure in live range DCE due to block pass
+ misoptimization). (Nikita)
+
- LDAP:
. Fixed bug #49876 (Fix LDAP path lookup on 64-bit distros). (dzuelke)
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index f36884fcd5..631798ec1b 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -792,8 +792,6 @@ optimize_const_unary_op:
}
opline++;
}
-
- strip_nops(op_array, block);
}
/* Rebuild plain (optimized) op_array from CFG */
@@ -1838,6 +1836,13 @@ void zend_optimize_cfg(zend_op_array *op_array, zend_optimizer_ctx *ctx)
zend_optimize_block(b, op_array, usage, &cfg, Tsource);
}
+ /* Eliminate NOPs */
+ for (b = blocks; b < end; b++) {
+ if (b->flags & ZEND_BB_REACHABLE) {
+ strip_nops(op_array, b);
+ }
+ }
+
/* Jump optimization for each block */
for (b = blocks; b < end; b++) {
if (b->flags & ZEND_BB_REACHABLE) {
diff --git a/ext/opcache/tests/bug75969.phpt b/ext/opcache/tests/bug75969.phpt
new file mode 100644
index 0000000000..733ab2f9b7
--- /dev/null
+++ b/ext/opcache/tests/bug75969.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #75969: Assertion failure in live range DCE due to block pass misoptimization
+--INI--
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--FILE--
+<?php
+
+// This is required for the segfault
+md5('foo');
+
+class Extended_Class {};
+$response = array(
+ 'a' => 'b'
+);
+new Extended_Class( array(
+ 'foo' => $response,
+ 'foo2' => 'bar2'
+) );
+
+?>
+===DONE===
+--EXPECT--
+===DONE===