From 80245fed95198870656db9568800a2e27d3c07e5 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Wed, 13 Mar 2024 16:24:44 +0000 Subject: [PATCH] apr_pools: Set APR_POOL_DEBUG's pool->owner before using the pool. The mutex synchronizing the pool in APR_POOL_DEBUG mode is created by apr_pool_create_ex_debug() on the created pool itself but before initialising the ->owner thread, so apr_thread_mutex_create() can abort() when reaching apr_pool_check_owner() if APR_POOL_DEBUG_OWNER is set. Move the ->owner initialisation before creating the ->mutex. Merges r1916282 from ^/apr/apr/branches/1.8.x Merges r1916278 from trunk. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1916283 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ memory/unix/apr_pools.c | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index d6890f87801..4fc23ee53e1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes for APR 1.7.5 + *) Fix crash in apr_pool_create() with --enable-pool-debug=all|owner. + [Yann Ylavic] + Changes for APR 1.7.4 *) Fix a regression where writing to a file opened with both APR_FOPEN_APPEND diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index 396506d7e79..ceb3dfb2209 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -2028,6 +2028,13 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, pool->tag = file_line; pool->file_line = file_line; +#if APR_HAS_THREADS + pool->owner = apr_os_thread_current(); +#endif /* APR_HAS_THREADS */ +#ifdef NETWARE + pool->owner_proc = (apr_os_proc_t)getnlmhandle(); +#endif /* defined(NETWARE) */ + #if APR_HAS_THREADS if (parent == NULL || parent->allocator != allocator) { apr_status_t rv; @@ -2067,13 +2074,6 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, pool->ref = NULL; } -#if APR_HAS_THREADS - pool->owner = apr_os_thread_current(); -#endif /* APR_HAS_THREADS */ -#ifdef NETWARE - pool->owner_proc = (apr_os_proc_t)getnlmhandle(); -#endif /* defined(NETWARE) */ - #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) apr_pool_log_event(pool, "CREATE", file_line, 1); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */