talloc-2.1.12 issues with library destructor

Andreas Schneider asn at samba.org
Mon Mar 26 16:34:52 UTC 2018


On Monday, 26 March 2018 18:12:26 CEST Ralph Böhme wrote:
> 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-de
> structor-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.

Which doesn't make sense if the default priority for the destructor is 65535 
and the max value too, then you can't run anything prior to the default 
destructors of other libraries.

https://github.com/gcc-mirror/gcc/blob/
7604a798428266cbeb56501b8f0f967676fe1205/gcc/tree.h

https://github.com/gcc-mirror/gcc/blob/
da8dff89fa9398f04b107e388cb706517ced9505/gcc/tree.c

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org





More information about the samba-technical mailing list