talloc: talloc_set_memlimit causes all reallocs to fail when used on pools. talloc_set_memlimit not enforced correctly on pools.

Jeremy Allison jra at samba.org
Fri Oct 16 20:25:28 UTC 2020

On Fri, Oct 16, 2020 at 03:04:36PM -0500, Arran Cudbard-Bell via samba-technical wrote:
> As for what the semantics should be, I was thinking that, yes,
> a pool in its entirety should be included in the memlimit calculation of
> its parent chunk, but if a memlimit is set on a pool directly,
> only the memory used by the children should be included in the
> memlimit check.
> I didn't get far enough into the code to see how many assumptions would be broken by this.

All of them I'd guess :-).

> An alternative that'd still satisfy our immediate need would be to have talloc_set_memlimit simply fail when someone tried to apply it to a pool (as you suggested), and add an optional flag that'd prevent allocations from occurring outside of the pool.

Please wrap your responses to 80 columns :-). Makes
quoting your replies really hard :-).

What you're asking for is more complexity in an
already overly complex part of the code (which
to be honest I wasn't even sure people were
using :-).

I think you can do what you need by allocating
a pool as a talloc child of a context, and setting
the memlimit on the that context.

More information about the samba-technical mailing list