Skip to content

Conversation

@nielsdos
Copy link
Member

For master (8.4-dev) I merged GH-13381. But that PR changes public API of TSRM, so cannot be used on lower branches.

This patch is a safe workaround for the issue with dynamic loaded modules, in combination with a existing fix using ifdef ZTS + if (module_started) inside pgsql and odbc. The idea is to delay unloading modules until the persistent resources are destroyed. This will keep the destructor code accessible in memory.

This is not a proper fix on its own, because we still need the workaround of not accessing globals after module destruction. The proper fix is in master.

Note: module_registry_unload_temp does not exist.

For master (8.4-dev) I merged phpGH-13381. But that PR changes public API
of TSRM, so cannot be used on lower branches.

This patch is a safe workaround for the issue, in combination with a
pre-existing fix using `ifdef ZTS + if (module_started)` inside pgsql
and odbc. The idea is to delay unloading modules until the persistent
resources are destroyed. This will keep the destructor code accessible
in memory.

This is not a proper fix on its own, because we still need the
workaround of not accessing globals after module destruction.
The proper fix is in master.
Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the patch is good on its own. And it may make sense to merge it to master as well.

May be it make sense to move zend_collect_dl_loaded_module_entries() code into zend_collect_module_handlers(), to do this uniformly.

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. */
Copy link
Member Author

@nielsdos nielsdos Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to move freeing module_request_startup_handlers to zend_unload_modules, but that changes public API.
And we want to avoid that in stable branches. The reason for this different workaround for lower branches was to avoid changing the public API in the first place.

@nielsdos nielsdos closed this in 2f60582 Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants