summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2017-01-24 11:32:04 +0100
committerNikita Popov <nikita.ppv@gmail.com>2017-01-24 11:32:41 +0100
commita1d5686a3c461f8e1b5833a14b699326b8e23987 (patch)
tree5222e43c78a3053fde5c681b958aae23a3b6dcf6 /Zend
parent08004d7959563a58bcf166b65589e769eba2f005 (diff)
downloadphp-git-a1d5686a3c461f8e1b5833a14b699326b8e23987.tar.gz
Fix assertion violation with composer
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/unused_shared_static_variables.phpt16
-rw-r--r--Zend/zend_opcode.c9
2 files changed, 24 insertions, 1 deletions
diff --git a/Zend/tests/unused_shared_static_variables.phpt b/Zend/tests/unused_shared_static_variables.phpt
new file mode 100644
index 0000000000..fc87a19f6a
--- /dev/null
+++ b/Zend/tests/unused_shared_static_variables.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Cleanup of shared static variables HT that has never been used should not assert
+--FILE--
+<?php
+
+class A {
+ public function test() {
+ static $x;
+ }
+}
+class B extends A {}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 438feb4c91..7c79703338 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -151,7 +151,14 @@ ZEND_API void zend_function_dtor(zval *zv)
ZEND_API void zend_cleanup_op_array_data(zend_op_array *op_array)
{
if (op_array->static_variables &&
- !(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)) {
+ !(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)
+ ) {
+ /* The static variables are initially shared when inheriting methods and will
+ * be separated on first use. If they are never used, they stay shared. Cleaning
+ * a shared static variables table is safe, as the intention is to clean all
+ * such tables. */
+ HT_ALLOW_COW_VIOLATION(op_array->static_variables);
+
zend_hash_clean(op_array->static_variables);
}
}