From d6315c2fbb46ea8795d2158e32c32f4111e805c1 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 17 Apr 2017 20:24:39 +0800 Subject: [PATCH] Fixed bug #74456 (Segmentation error while running a script in CLI mode) Instead of make update_op1_by_const supports FETCH_LIST(CASE), I think disable it is more safe for 7.1 --- NEWS | 2 ++ ext/opcache/Optimizer/block_pass.c | 2 +- ext/opcache/tests/bug74456.phpt | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/bug74456.phpt diff --git a/NEWS b/NEWS index 05c8246e96..02d5e0a734 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,8 @@ PHP NEWS . Fixed bug #74439 (wrong reflection for Locale methods). (villfa) - Opcache: + . Fixed bug #74456 (Segmentation error while running a script in CLI mode). + (Laruence) . Fixed bug #74431 (foreach infinite loop). (Nikita) . Fixed bug #74442 (Opcached version produces a nested array). (Nikita) diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index bf411f4e77..ee4b5516a9 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -165,7 +165,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array COPY_NODE(opline->op1, src->op1); VAR_SOURCE(op1) = NULL; MAKE_NOP(src); - } else { + } else if (opline->opcode != ZEND_FETCH_LIST && opline->opcode != ZEND_CASE) { zval c = ZEND_OP1_LITERAL(src); zval_copy_ctor(&c); if (zend_optimizer_update_op1_const(op_array, opline, &c)) { diff --git a/ext/opcache/tests/bug74456.phpt b/ext/opcache/tests/bug74456.phpt new file mode 100644 index 0000000000..9c9a286e2f --- /dev/null +++ b/ext/opcache/tests/bug74456.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #74456 (Segmentation error while running a script in CLI mode) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(0) +int(1) +int(2) -- 2.50.1