mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Implement a more granular shutdown mechanism for the executor -
prevent corruption of constants and missing destructions of resources
This commit is contained in:
parent
13ac04b8e5
commit
8084d27885
3 changed files with 62 additions and 34 deletions
|
@ -536,9 +536,8 @@ void zend_deactivate(CLS_D ELS_DC)
|
|||
if (setjmp(EG(bailout))==0) {
|
||||
shutdown_scanner(CLS_C);
|
||||
}
|
||||
if (setjmp(EG(bailout))==0) {
|
||||
/* shutdown_executor() takes care of its own bailout handling */
|
||||
shutdown_executor(ELS_C);
|
||||
}
|
||||
if (setjmp(EG(bailout))==0) {
|
||||
shutdown_compiler(CLS_C);
|
||||
}
|
||||
|
|
|
@ -152,6 +152,7 @@ void init_executor(CLS_D ELS_DC)
|
|||
|
||||
void shutdown_executor(ELS_D)
|
||||
{
|
||||
if (setjmp(EG(bailout))==0) {
|
||||
zend_ptr_stack_destroy(&EG(arg_types_stack));
|
||||
|
||||
while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
|
||||
|
@ -174,11 +175,13 @@ void shutdown_executor(ELS_D)
|
|||
/* Destroy all op arrays */
|
||||
zend_hash_apply(EG(function_table), (int (*)(void *)) is_not_internal_function);
|
||||
zend_hash_apply(EG(class_table), (int (*)(void *)) is_not_internal_class);
|
||||
}
|
||||
|
||||
zend_destroy_rsrc_list(ELS_C); /* must be destroyed after the main symbol table and
|
||||
* op arrays are destroyed.
|
||||
*/
|
||||
|
||||
if (setjmp(EG(bailout))==0) {
|
||||
clean_non_persistent_constants();
|
||||
#if ZEND_DEBUG
|
||||
signal(SIGSEGV, original_sigsegv_handler);
|
||||
|
@ -196,6 +199,7 @@ void shutdown_executor(ELS_D)
|
|||
|
||||
EG(error_reporting) = EG(orig_error_reporting);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API char *get_active_function_name()
|
||||
|
|
|
@ -231,8 +231,33 @@ int zend_init_rsrc_plist(ELS_D)
|
|||
|
||||
void zend_destroy_rsrc_list(ELS_D)
|
||||
{
|
||||
zend_hash_reverse_destroy(&EG(regular_list));
|
||||
Bucket *p, *q;
|
||||
HashTable *ht = &EG(regular_list);
|
||||
|
||||
while (1) {
|
||||
p = ht->pListTail;
|
||||
if (!p) {
|
||||
break;
|
||||
}
|
||||
q = p->pListLast;
|
||||
if (q) {
|
||||
q->pListNext = NULL;
|
||||
}
|
||||
ht->pListTail = q;
|
||||
|
||||
if (ht->pDestructor) {
|
||||
if (setjmp(EG(bailout))==0) {
|
||||
ht->pDestructor(p->pData);
|
||||
}
|
||||
}
|
||||
if (!p->pDataPtr && p->pData) {
|
||||
pefree(p->pData, ht->persistent);
|
||||
}
|
||||
pefree(p, ht->persistent);
|
||||
}
|
||||
pefree(ht->arBuckets, ht->persistent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void zend_destroy_rsrc_plist(ELS_D)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue