talloc: talloc_free_children vs. _talloc_free_internal and memory leaks

Stefan (metze) Metzmacher metze at samba.org
Sat Apr 9 04:09:43 MDT 2011


Hi,

I found that talloc_free_children() used to have the same logic as
_talloc_free_internal(),
but some fixes went only into _talloc_free_internal().

That's why I created a  _talloc_free_children_internal() function.

I think using the TALLOC_FLAG_LOOP detection for the talloc_free_children()
should not be a problem, if it is we can move it to the caller.

I got to it because of a memory leak in test_talloc_free_in_destructor().
There we create a parent child loop and as result the memory chunks
went out of the scope of the null_context, which means it's hard to detect
the leak (but valgrind did :-).

I have a simple fix that only prevents the parent child loop.
DISCUSS:SIMPLE FIX talloc: improve the new_parent detection for
abandoned children

And a more advanced change that tries to find a better new parent
if a child is protected by a destructor. (But I'm not sure if the fix is
correct...)
DISCUSS:COMPLEX FIX talloc: _talloc_free_children_internal more complex
search for new parent

The code can be found here:
http://gitweb.samba.org/?p=metze/samba/wip.git;a=shortlog;h=refs/heads/master4-talloc

Is it ok to push everything without HACK, TODO, DISCUSS markers in the
commit message?

metze

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20110409/8334d24c/attachment.pgp>


More information about the samba-technical mailing list