Skip to content

Commit 197095c

Browse files
committed
Merge branch 'pull-request/770' into PHP-5.4
* pull-request/770: Only destruct if EG(active) in zend_shutdown(). (bug #65463, #66036) Fix typo from commit 32314f6 Fix destruction order in zend_shutdown (bug #65463, #66036)
2 parents e665a07 + 437612f commit 197095c

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Zend/zend.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,20 @@ void zend_shutdown(TSRMLS_D) /* {{{ */
813813
zend_shutdown_timeout_thread();
814814
#endif
815815
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
816+
817+
if (EG(active))
818+
{
819+
/*
820+
* The order of destruction is important here.
821+
* See bugs #65463 and 66036.
822+
*/
823+
zend_hash_reverse_apply(GLOBAL_FUNCTION_TABLE, (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);
824+
zend_hash_reverse_apply(GLOBAL_CLASS_TABLE, (apply_func_t) zend_cleanup_user_class_data TSRMLS_CC);
825+
zend_cleanup_internal_classes(TSRMLS_C);
826+
zend_hash_reverse_apply(GLOBAL_FUNCTION_TABLE, (apply_func_t) clean_non_persistent_function_full TSRMLS_CC);
827+
zend_hash_reverse_apply(GLOBAL_CLASS_TABLE, (apply_func_t) clean_non_persistent_class_full TSRMLS_CC);
828+
}
829+
816830
zend_destroy_modules();
817831

818832
zend_hash_destroy(GLOBAL_FUNCTION_TABLE);

Zend/zend_compile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,8 @@ ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC);
639639
ZEND_API void zend_cleanup_internal_classes(TSRMLS_D);
640640
ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC);
641641
ZEND_API int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC);
642+
ZEND_API int clean_non_persistent_function_full(zend_function *function TSRMLS_DC);
643+
ZEND_API int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC);
642644

643645
ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC);
644646
ZEND_API void zend_function_dtor(zend_function *function);

Zend/zend_execute_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int clean_non_persistent_function(zend_function *function TSRMLS_DC) /* {
108108
}
109109
/* }}} */
110110

111-
static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) /* {{{ */
111+
ZEND_API int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) /* {{{ */
112112
{
113113
return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
114114
}
@@ -120,7 +120,7 @@ static int clean_non_persistent_class(zend_class_entry **ce TSRMLS_DC) /* {{{ */
120120
}
121121
/* }}} */
122122

123-
static int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) /* {{{ */
123+
ZEND_API int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) /* {{{ */
124124
{
125125
return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
126126
}

0 commit comments

Comments
 (0)