]> granicus.if.org Git - php/commitdiff
Fixed bug #76446 (zend_variables.c:73: zend_string_destroy: Assertion `!(zval_gc_flag...
authorXinchen Hui <laruence@gmail.com>
Wed, 13 Jun 2018 07:06:51 +0000 (15:06 +0800)
committerXinchen Hui <laruence@gmail.com>
Wed, 13 Jun 2018 07:06:51 +0000 (15:06 +0800)
NEWS
ext/opcache/Optimizer/dce.c
ext/opcache/tests/bug76446.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 13453f50a788e58bbc91d93f1a3c68ea82472deb..3b2ca4389a9a1b18987d8ae32a17efffbab1eb8c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,8 @@ PHP                                                                        NEWS
 
 - Opcache:
   . Fixed bug #76463 (var has array key type but not value type). (Laruence)
+  . Fixed bug #76446 (zend_variables.c:73: zend_string_destroy: Assertion
+    `!(zval_gc_flags((str)->gc)). (Nikita, Laruence)
 
 - ZIP:
   . Fixed bug #76461 (OPSYS_Z_CPM defined instead of OPSYS_CPM).
index 4a35c9e5d3ecc37f277fe37935f7b9370bbb5145..58925975cadb4ca083cd67be0d30467b52c0b3fe 100644 (file)
@@ -39,7 +39,7 @@
  *    postdominator tree and of postdominance frontiers, which does not seem worthwhile at this
  *    point.
  *  * We separate intrinsic side-effects from potential side-effects in the form of notices thrown
- *    by the instruction (in case we want to make this configurable). See may_have_side_effect() and
+ *    by the instruction (in case we want to make this configurable). See may_have_side_effects() and
  *    zend_may_throw().
  *  * We often cannot DCE assignments and unsets while guaranteeing that dtors run in the same
  *    order. There is an optimization option to allow reordering of dtor effects.
@@ -109,7 +109,6 @@ static inline zend_bool may_have_side_effects(
                case ZEND_CAST:
                case ZEND_ROPE_INIT:
                case ZEND_ROPE_ADD:
-               case ZEND_ROPE_END:
                case ZEND_INIT_ARRAY:
                case ZEND_ADD_ARRAY_ELEMENT:
                case ZEND_SPACESHIP:
@@ -127,6 +126,9 @@ static inline zend_bool may_have_side_effects(
                case ZEND_FUNC_GET_ARGS:
                        /* No side effects */
                        return 0;
+               case ZEND_ROPE_END:
+                       /* TODO: Rope dce optmization, see #76446 */
+                       return 1;
                case ZEND_JMP:
                case ZEND_JMPZ:
                case ZEND_JMPNZ:
diff --git a/ext/opcache/tests/bug76446.phpt b/ext/opcache/tests/bug76446.phpt
new file mode 100644 (file)
index 0000000..dfb676f
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #76446 (zend_variables.c:73: zend_string_destroy: Assertion `!(zval_gc_flags((str)->gc)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function test()
+{
+       $openmenu = '';
+       $openstr2 = "&amp;openmenu={$openmenu}{$addlang}\"";
+       return 0;
+}
+
+var_dump(test());
+?>
+--EXPECTF--
+Notice: Undefined variable: addlang in %sbug76446.php on line %d
+int(0)