ldb and talloc trees

Andrew Bartlett abartlet at samba.org
Fri Jun 22 05:20:32 UTC 2018


On Fri, 2018-06-15 at 13:08 +0200, Volker Lendecke via samba-technical
wrote:
> On Fri, Jun 15, 2018 at 09:25:08AM +0200, Volker Lendecke via samba-technical wrote:
> > If talloc_tos() is no longer en vogue, we need a similarly concise
> > abstraction.
> 
> Another one that just came in:
> 
> https://lists.samba.org/archive/samba-technical/2018-June/128427.html
> 
> I'm not saying that we should use talloc_tos() deep inside ldb, but if
> you want to ditch it, please provide something of similar
> functionality to avoid hickups like the ones Andrej found. That is
> precisely the kind of memory leak that I've tried to prevent with
> talloc_tos(). We NEED something like that. Please consider these cases
> when you say that talloc_tos() needs to be avoided.

I agree that a short-lived context should be used.  Sadly this code in
ldb dates from before talloc (if I recall it was originally planned to
allow a pluggable allocator), and was transitioned over to pure talloc
without a proper conversion to a tree, hence why things are a mess
there.

talloc_tos() and the stackframe stuff isn't avaialble in ldb, but a
pattern of allocating on a context from talloc_new(), and if required
pushing to a parent context via talloc_steal() should be used.

Andrew Bartlett

-- 
Andrew Bartlett
https://samba.org/~abartlet/
Authentication Developer, Samba Team         https://samba.org
Samba Development and Support, Catalyst IT   
https://catalyst.net.nz/services/samba







More information about the samba-technical mailing list