talloc-2.1.12 issues with library destructor

Ralph Böhme slow at samba.org
Mon Mar 26 16:12:26 UTC 2018


On Mon, Mar 26, 2018 at 06:00:59PM +0200, Andreas Schneider wrote:
> On Monday, 26 March 2018 16:06:26 CEST 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()!
> > 
> > while I agree that we should work on deprecating and later removing
> > talloc_autofree, it's currently used and the recent change in commit
> > 41b6810ba01f44537f470c806adb8686e1a39c48 in talloc which was aimed at fixing
> > long standing Samba bug 7587 seems to cause this regression.
> > 
> > We could try throwing destructor priorizy INT_MAX at the problem hoping
> > noone else uses such a high value.
> 
> Ah, now I got it, however it is the reverse:
> 
> +/* The initialization priority for entities for which no explicit
> +   initialization priority has been specified.  */
> +#define DEFAULT_INIT_PRIORITY 65535
> +
> +/* The maximum allowed initialization priority.  */
> +#define MAX_INIT_PRIORITY 65535
> +
> +/* The largest priority value reserved for use by system runtime
> +   libraries.  */
> +#define MAX_RESERVED_INIT_PRIORITY 100
> 
> So you need to set it to 101.

<https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-destructor-function-attribute>

  You may provide an optional integer priority to control the order in which
  constructor and destructor functions are run. A constructor with a smaller
  priority number runs before a constructor with a larger priority number; the
  opposite relationship holds for destructors.

As we want to ensure the talloc destructor gets kicked of first to resemble
atexit() ordering, iiuc we must use MAX_INIT_PRIORITY.

-slow

-- 
Ralph Boehme, Samba Team       https://samba.org/
Samba Developer, SerNet GmbH   https://sernet.de/en/samba/
GPG Key Fingerprint:           FAE2 C608 8A24 2520 51C5
                               59E4 AA1E 9B71 2639 9E46



More information about the samba-technical mailing list