[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: FW: atexit-handler causes segfault when dlopen-ed libldap is unloaded prior to program termination (ITS#1577)

> -----Original Message-----
> From: Kurt D. Zeilenga [mailto:Kurt@OpenLDAP.org]
> At 04:13 PM 2002-02-04, Howard Chu wrote:
> >Perhaps we should instead have a public ldap_pvt_destroy() function that
> >callers explicitly used to clean up the LDAP library?
> My thoughts are to have a init()/destroy() function pair.
> If the init() function is called as the first function,
> then the atexit() handler will be avoided and a destroy()
> call expected.
>         ldap_x_initialize();
>         ldap_x_destroy();
> I suspect that dlopen/dlclose() provides a means for library
> init/destroy routines to be called.  A little glue would
> be nice.

Yes, this all makes sense. The only complication is for systems that
use a different mechanism for dynamic linking support, but those are
getting fewer. If we can rely on it, we don't need an atexit handler
at all since the library's destructor will be called at exit time
anyway. I can quickly patch this for Linux and Solaris, should work
on any ELF-based system. Dunno about other platforms at the moment.

For ELF we just need to provide _init() and _fini() entry points.
Really it appears we just need to rename our atexit handler to _fini()
and remove the call to atexit:

#define	LDAP_DESTROY	_fini
	(I dunno...)


  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc  
  Symas: Premier OpenSource Development and Support