talloc null context thread safe ?

Andrew Bartlett abartlet at samba.org
Mon Nov 6 22:42:16 GMT 2006

On Mon, 2006-11-06 at 23:19 +0100, Rémi wrote:
> Hello,
> I am using talloc in a project other than Samba : I hope this is the right 
> list for my question.

I think so (that is, I know of no better place to ask).

> I understand that talloc does not deal with threads, and in fact, it is thread 
> safe, as long as each thread uses different memory contexts. If two threads 
> uses the same context then they need to synchronise in order to be safe.
> Am I correct ?


> If so, my concern is with the allocation of "top-level" contexts i.e. when 
> using a NULL parent. When using the "talloc_enable_leak_report", I understand 
> that the NULL context is in fact a hidden "null context" global variable, so 
> allocating anything from the NULL context (e.g. tmp_ctx = talloc_new (NULL)) 
> is no longer thread safe. Am I missing something, or may be this is obvious ?
> So in multi-thread environement, I should never use a NULL context as a parent 
> (may be instead define my own per-thread null-context). 

In short, you should never use the NULL context, particularly in your

Andrew Bartlett

Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org
Samba Developer, Red Hat Inc.                  http://redhat.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20061107/060d758a/attachment.bin

More information about the samba-technical mailing list