From: Nikita Popov Date: Tue, 24 Jan 2017 10:32:04 +0000 (+0100) Subject: Fix assertion violation with composer X-Git-Tag: php-7.2.0alpha1~473 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1d5686a3c461f8e1b5833a14b699326b8e23987;p=php Fix assertion violation with composer --- 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-- + +===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); } }