PATCH : talloc-2.0.1 to add support for static talloc pools

Karthick A R karthick.linuxdreamer at gmail.com
Tue Feb 1 18:06:28 MST 2011


On Tue, Feb 1, 2011 at 4:57 AM, Rusty Russell <rusty at rustcorp.com.au> wrote:

> On Wed, 19 Jan 2011 01:19:38 pm Karthick A R wrote:
> > Hi,
> >  Please find attached a patch that would apply clean on top of talloc
> 2.0.1
> > that adds support for static talloc pools.
>
> Hmm, there are also other allocation patches floating around, I wonder
> if it makes sense to consider them as a group.  Here are the CCAN
> ones:
>
> 1) TALLOC_EXTERNAL: an alternate allocator flag, and any children of a
>   TALLOC_EXTERNAL are allocated using the alternate allocator hook.
> 2) talloc_set_allocator() which replaces malloc/free/realloc for all
>   talloc allocations.
>
> The former I use for libantithread, the latter for failtest.  But I
> think the former could be used to implement static pools.
>
>
Yes. Makes sense for me to use the external hook for static pools. I wasn't
aware about the other 2 patches though.
If you can point me to those patches, I can try integrating the changes with
the external hook (though it could be outside talloc domain)

Also the static pool patch addressed a nested pool issue with talloc pools.
The test in my github when run without the static pool changes test (talloc
2.0.1/5) crashes talloc :
https://github.com/karthick18/talloc/blob/master/talloc_test.c

Basically this use-case:
void *poolfoo = talloc_pool(parent, sizeof(struct foo) * 1024);
void *poolbar = talloc_pool(poolfoo, sizeof(struct bar) * 100); /* subpool*/

Trying to talloc_free(poolbar) would cause a crash currently as it tries to
free(poolbar) when its a POOLMEM of poolfoo. The patch also addresses this
by trying to trace the parent of the subpool to free the subpool to the
parent pool context.

Regards,
-Karthick


-- 
Software is like sex: it's better when it's free.
-Linus Torvalds

A.R.Karthick
http://github.com/karthick18


More information about the samba-technical mailing list