From ec5ba5d3827a794e1f3d0eff8d9691edaeb96b9f Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Wed, 27 Sep 2017 16:28:09 +0000 Subject: [PATCH] core: deregister all hooks before leaving pconf, otherwise some late cleanup or function call (e.g. ap_log) may use one while DSOs are unloaded. See PR 61558 (double/second fault). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1809881 13f79535-47bb-0310-9956-ffa450edef68 --- server/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/main.c b/server/main.c index 5196903ce7..e67c001d37 100644 --- a/server/main.c +++ b/server/main.c @@ -295,6 +295,13 @@ static int abort_on_oom(int retcode) return retcode; /* unreachable, hopefully. */ } +static apr_status_t deregister_all_hooks(void *unused) +{ + (void)unused; + apr_hook_deregister_all(); + return APR_SUCCESS; +} + static process_rec *init_process(int *argc, const char * const * *argv) { process_rec *process; @@ -497,6 +504,10 @@ int main(int argc, const char * const argv[]) } #endif + /* Deregister all hooks (lastly) when done with pconf */ + apr_pool_cleanup_register(pconf, NULL, deregister_all_hooks, + apr_pool_cleanup_null); + apr_pool_create(&pcommands, ap_pglobal); apr_pool_tag(pcommands, "pcommands"); ap_server_pre_read_config = apr_array_make(pcommands, 1, @@ -743,10 +754,13 @@ int main(int argc, const char * const argv[]) do { ap_main_state = AP_SQ_MS_DESTROY_CONFIG; - apr_hook_deregister_all(); apr_pool_clear(pconf); ap_clear_auth_internal(); + /* Deregister all hooks (lastly) when done with pconf */ + apr_pool_cleanup_register(pconf, NULL, deregister_all_hooks, + apr_pool_cleanup_null); + ap_main_state = AP_SQ_MS_CREATE_CONFIG; ap_config_generation++; for (mod = ap_prelinked_modules; *mod != NULL; mod++) { -- 2.40.0