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.


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
  • Loading branch information
ylavic committed Mar 13, 2024
1 parent 15f96a0 commit 80245fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions memory/unix/apr_pools.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) */
Expand Down

0 comments on commit 80245fe

Please sign in to comment.