You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Sebastian Morawietz <se...@lexisnexis.de> on 2005/12/16 10:35:03 UTC

Creating Root-Pools and apr_pool_cleanup_register

Hello,

Quite a while ago I began migration a C-Application to use APR, first  
for file-io / locking only ( now also memory management and error- 
handling ).

Since it is not really easy to integrate apr memory-management into  
an existing application ( changing all the function signatures to  
take and apr-pool etc. ) there are still some few functions, that  
create an apr-pool with NULL as parent-parameter.
This works nice, until I was playing around with  
apr_pool_cleanup_register to free memory allocated on the heap by  
other library methods.

In the Unit-tests I got application crashes (double free), which can  
generally be traced back to apr_terminate calling cleanup-methods,  
that were already called by apr_pool_destroy before, but _ONLY_, if  
there is more than one root-pool created.
So my question is: Is it to be generally considered dangerous to have  
more than one root-pool in an application, or might there be another  
problem in my application, that I have to spend some extra-thinking  
on (this stuff is disgustingly hard to debug ;)?

Greetings
Sebastian

Re: Creating Root-Pools and apr_pool_cleanup_register

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 12/16/05, Sebastian Morawietz <se...@lexisnexis.de> wrote:

> So my question is: Is it to be generally considered dangerous to have
> more than one root-pool in an application, or might there be another
> problem in my application, that I have to spend some extra-thinking
> on (this stuff is disgustingly hard to debug ;)?

In theory there should be no problem having multiple root level pools.
 Subversion uses new top level pools for each new error object it
creates, for example, and we haven't had any problems with it.  I'd
expect that there's probably some other problem going on here, and
that the multiple root level pools is not the cause of your issue.

-garrett