Bug 58152 - apr_pool_create returns the same pool (pointer) after multiple invocations with allocator = NULL
Summary: apr_pool_create returns the same pool (pointer) after multiple invocations wi...
Status: NEW
Alias: None
Product: APR
Classification: Unclassified
Component: APR (show other bugs)
Version: 1.5.2
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-19 22:16 UTC by jared.breeden
Modified: 2015-07-19 22:16 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jared.breeden 2015-07-19 22:16:57 UTC
Calling `apr_pool_create_ex` with no abort_fn or allocator (as is the case with the `apr_pool_create(**pool, *parent)` macro) begins to return the same pool over and over. In my current program, it happens on the third invocation each time, and then sporadically from then on. It happens the same whether I pass in a parent pool or not.

Obviously this creates a problem, as when I later attempt to destroy a pool that I *think* only contains a certain set of objects, I'm actually destroying many more.

In the output below, I'm logging all pool creations and destructions.

```
Created pool: 0x7f98f282ea28
Created pool: 0x7f98f283b628
Created pool: 0x7f98f306bc28 < These are the same
Created pool: 0x7f98f306bc28 < These are the same
Created pool: 0x7f98f3803028
...
Destroying pool: 0x7f98f306bc28 < These should be freeing...
Destroying pool: 0x7f98f306bc28 < independent sets of objects...
Destroying pool: 0x7f98f3805028
Destroying pool: 0x7f98f3803028
Destroying pool: 0x7f98f306bc28 < but they are trampling each other...
Destroying pool: 0x7f98f306bc28 < instead.
```

Note this is a single threaded application. Each call is made like this:

```
apr_initialize();
...
apr_pool_t* native_pool = NULL;
apr_pool_create_ex(&native_pool, NULL, NULL, NULL);
```

If I create a new allocator for each pool, then all is well.

Is this expected behavior? I'm guessing `apr_pool_create` should always return a new pool.