talloc_reference() (again)

Andrew Bartlett abartlet at samba.org
Wed Oct 16 19:54:11 MDT 2013


(resend with correct sender address)

On Wed, 2013-10-16 at 07:42 -0400, Simo wrote:

> +1 the evilness of talloc_reference is that an arbitrary *user* of the
> memory can change the semantics for *all* others, this is a recipe for
> disaster and the reason this API must be discouraged and eventually
> dumped.

This is perhaps the best explanation of the issues.  The graph issue is 
important, but the behaviour change on talloc_free() is the real hard part of this problem. 

This is why I think the idea proposed (but never taken anywhere) of 
a talloc_may_reference() is the best that I've seen for handling 
objects that need to be reference counted, either internally or 
because they are exposed to another reference-based system, such 
as python.  The proposal is that this call would then set referenced
semantics on an object, regardless of if it was actually referenced,
keeping behaviour like 'must talloc_unlink()' consistent. 

That discussion was here:
https://lists.samba.org/archive/samba-technical/2011-October/080045.html

Alternately, metze suggested some patterns, which I think are the same that Volker was referring to, to make talloc_reference less of an issue here:
https://lists.samba.org/archive/samba-technical/2011-October/080102.html

I'm not dogmatic about this, and I'm very happy to review patches that
improve this situation, while not loosing functionality.  One of the
joys of reviewing metze's merge work (rather than doing it myself) is
that:  
 - metze doesn't like talloc_reference()
 - metze finds creative ways to merge code that avoids the need for it in the first place

Thanks,

Andrew Bartlett


-- 
Andrew Bartlett
http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org
Samba Developer, Catalyst IT                   http://catalyst.net.nz


-- 
Andrew Bartlett
http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org
Samba Developer, Catalyst IT                   http://catalyst.net.nz




More information about the samba-technical mailing list