mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Workaround ZTS persistent resource crashes (PHP 8.3 and lower)
This commit is contained in:
commit
3ab7aa001f
3
NEWS
3
NEWS
@ -2,6 +2,9 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.3.4
|
||||
|
||||
- Core:
|
||||
. Fix ZTS persistent resource crashes on shutdown. (nielsdos)
|
||||
|
||||
- Curl:
|
||||
. Fix failing tests due to string changes in libcurl 8.6.0. (Ayesh)
|
||||
|
||||
|
@ -1167,6 +1167,8 @@ void zend_shutdown(void) /* {{{ */
|
||||
#endif
|
||||
zend_destroy_rsrc_list_dtors();
|
||||
|
||||
zend_unload_modules();
|
||||
|
||||
zend_optimizer_shutdown();
|
||||
startup_done = false;
|
||||
}
|
||||
|
@ -279,6 +279,7 @@ void zend_shutdown(void);
|
||||
void zend_register_standard_ini_entries(void);
|
||||
zend_result zend_post_startup(void);
|
||||
void zend_set_utility_values(zend_utility_values *utility_values);
|
||||
void zend_unload_modules(void);
|
||||
|
||||
ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno);
|
||||
ZEND_API size_t zend_get_page_size(void);
|
||||
|
@ -41,6 +41,7 @@ ZEND_API HashTable module_registry;
|
||||
static zend_module_entry **module_request_startup_handlers;
|
||||
static zend_module_entry **module_request_shutdown_handlers;
|
||||
static zend_module_entry **module_post_deactivate_handlers;
|
||||
static zend_module_entry **modules_dl_loaded;
|
||||
|
||||
static zend_class_entry **class_cleanup_handlers;
|
||||
|
||||
@ -2368,6 +2369,7 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
|
||||
int startup_count = 0;
|
||||
int shutdown_count = 0;
|
||||
int post_deactivate_count = 0;
|
||||
int dl_loaded_count = 0;
|
||||
zend_class_entry *ce;
|
||||
int class_count = 0;
|
||||
|
||||
@ -2382,6 +2384,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
|
||||
if (module->post_deactivate_func) {
|
||||
post_deactivate_count++;
|
||||
}
|
||||
if (module->handle) {
|
||||
dl_loaded_count++;
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
module_request_startup_handlers = (zend_module_entry**)realloc(
|
||||
module_request_startup_handlers,
|
||||
@ -2394,6 +2399,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
|
||||
module_request_shutdown_handlers[shutdown_count] = NULL;
|
||||
module_post_deactivate_handlers = module_request_shutdown_handlers + shutdown_count + 1;
|
||||
module_post_deactivate_handlers[post_deactivate_count] = NULL;
|
||||
/* Cannot reuse module_request_startup_handlers because it is freed in zend_destroy_modules, which happens before zend_unload_modules. */
|
||||
modules_dl_loaded = realloc(modules_dl_loaded, sizeof(zend_module_entry*) * (dl_loaded_count + 1));
|
||||
modules_dl_loaded[dl_loaded_count] = NULL;
|
||||
startup_count = 0;
|
||||
|
||||
ZEND_HASH_MAP_FOREACH_PTR(&module_registry, module) {
|
||||
@ -2406,6 +2414,9 @@ ZEND_API void zend_collect_module_handlers(void) /* {{{ */
|
||||
if (module->post_deactivate_func) {
|
||||
module_post_deactivate_handlers[--post_deactivate_count] = module;
|
||||
}
|
||||
if (module->handle) {
|
||||
modules_dl_loaded[--dl_loaded_count] = module;
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
/* Collect internal classes with static members */
|
||||
@ -3180,18 +3191,23 @@ void module_destructor(zend_module_entry *module) /* {{{ */
|
||||
clean_module_functions(module);
|
||||
}
|
||||
|
||||
#if HAVE_LIBDL
|
||||
if (module->handle && !getenv("ZEND_DONT_UNLOAD_MODULES")) {
|
||||
DL_UNLOAD(module->handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ZEND_RC_DEBUG
|
||||
zend_rc_debug = orig_rc_debug;
|
||||
#endif
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void module_registry_unload(const zend_module_entry *module)
|
||||
{
|
||||
#if HAVE_LIBDL
|
||||
if (!getenv("ZEND_DONT_UNLOAD_MODULES")) {
|
||||
DL_UNLOAD(module->handle);
|
||||
}
|
||||
#else
|
||||
ZEND_IGNORE_VALUE(module);
|
||||
#endif
|
||||
}
|
||||
|
||||
ZEND_API void zend_activate_modules(void) /* {{{ */
|
||||
{
|
||||
zend_module_entry **p = module_request_startup_handlers;
|
||||
@ -3236,6 +3252,18 @@ ZEND_API void zend_deactivate_modules(void) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_unload_modules(void) /* {{{ */
|
||||
{
|
||||
zend_module_entry **modules = modules_dl_loaded;
|
||||
while (*modules) {
|
||||
module_registry_unload(*modules);
|
||||
modules++;
|
||||
}
|
||||
free(modules_dl_loaded);
|
||||
modules_dl_loaded = NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
|
||||
{
|
||||
if (EG(full_tables_cleanup)) {
|
||||
@ -3254,6 +3282,9 @@ ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
|
||||
break;
|
||||
}
|
||||
module_destructor(module);
|
||||
if (module->handle) {
|
||||
module_registry_unload(module);
|
||||
}
|
||||
zend_string_release_ex(key, 0);
|
||||
} ZEND_HASH_MAP_FOREACH_END_DEL();
|
||||
} else {
|
||||
|
@ -125,7 +125,7 @@ extern ZEND_API HashTable module_registry;
|
||||
|
||||
void module_destructor(zend_module_entry *module);
|
||||
int module_registry_request_startup(zend_module_entry *module);
|
||||
int module_registry_unload_temp(const zend_module_entry *module);
|
||||
void module_registry_unload(const zend_module_entry *module);
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user