talloc-2.1.12 issues with library destructor
Jeremy Allison
jra at samba.org
Mon Mar 26 17:16:50 UTC 2018
On Mon, Mar 26, 2018 at 05:00:15PM +0200, Lukas Slebodnik via samba-technical wrote:
> On (26/03/18 16:06), Ralph Böhme wrote:
> >Hi Andreas,
> >
> >On Mon, Mar 26, 2018 at 03:01:56PM +0200, Andreas Schneider via samba-technical wrote:
> >> destructors are normally executed after the program returns from main() or
> >> after exit() is called. talloc tries to clean up its null context memory and
> >> you have obviously a talloc destructor defined for your kcm_data talloc
> >> context!
> >>
> >> I don't thinks this is an issue in talloc, but sssd should cleanup the memory
> >> in orderly_shutdown() before it calls exit()!
> >
>
> SSSD allocated memory on context returned by talloc_autofree_context.
> And I assume it was used due to following parts in documentation
>
> """
> * @brief Provide a talloc context that is freed at program exit.
> *
> * This is a handy utility function that returns a talloc context
> * which will be automatically freed on program exit. This can be used
> * to reduce the noise in memory leak reports.
> """
>
> And it is not clear which library destructor will be called
> before talloc. Therefore it might be difficult to rely on talloc_destructors
> releasing properly data allocated under autofree_context.
>
> Sure, sssd can release memory before calling exit e.g.
> talloc_free(talloc_autofree_context());
> But then we loose an advantage of relying on automatic release
> provided by talloc_autofree_context.
Do not use talloc_autofree_context. It's addition to talloc
was a *big* API mistake, and I'm trying to remove it from
Samba in call cases.
More information about the samba-technical
mailing list