Skip to content

Commit

Permalink
apr_pools: Set APR_POOL_DEBUG's pool->owner before using the pool.
Browse files Browse the repository at this point in the history
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.



git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1916278 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ylavic committed Mar 13, 2024
1 parent 96f9855 commit 258fe58
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions memory/unix/apr_pools.c
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,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;
Expand Down Expand Up @@ -2095,13 +2102,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) */
Expand Down

0 comments on commit 258fe58

Please sign in to comment.