From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 1 15:40:26 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E63C516A41A for ; Tue, 1 Jan 2008 15:40:26 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.250]) by mx1.freebsd.org (Postfix) with ESMTP id 9AAEE13C4D9 for ; Tue, 1 Jan 2008 15:40:26 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: by an-out-0708.google.com with SMTP id c14so1056634anc.13 for ; Tue, 01 Jan 2008 07:40:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; bh=JiOU2g+BXUckPkn7v4oahALbim84hTM8ErAhVYYQNQE=; b=WZnB53oEx6fxCfuhsDV5G7zb/1ZCz6IJ+vUxO07qUSJ7j9hUJWkTlNc+1kgM0GU9/PruN5nRJvgaG+pU5KbpglbkfBRjqjR+GiLxllcTbYyjPORjcGgzoUel7tEuHyjY3sTzoGavPMOw6g8Zh9wLqoTAysC+0F+P8BHzEyY/mtY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; b=JwDXnvuPVEDWA9xd/Zxg+C2EVtAxp4vZBIi9TrFAV0sCFKIkLEmid9z697oSn1Qt54s+4WeDUThYMDVeswH9eM+xMTzs9b+ZIl27EaXVNdiZ1obWXoo2EiJO0Y+hiA3frS978fR3Eg91wqFsqtz9iVoIEwsdJPabW/9RXzfDZOw= Received: by 10.101.68.19 with SMTP id v19mr28065847ank.4.1199202025908; Tue, 01 Jan 2008 07:40:25 -0800 (PST) Received: from kan.dnsalias.net ( [24.218.183.247]) by mx.google.com with ESMTPS id 31sm13055388wri.24.2008.01.01.07.40.23 (version=SSLv3 cipher=OTHER); Tue, 01 Jan 2008 07:40:24 -0800 (PST) Date: Tue, 1 Jan 2008 10:40:18 -0500 From: Alexander Kabaev To: Tim Kientzle Message-ID: <20080101104018.0fe51d67@kan.dnsalias.net> In-Reply-To: <4779AD03.1060505@freebsd.org> References: <18297.6718.750894.937199@yeti.mininet> <20071231142620.39f2fbd2@kan.dnsalias.net> <18297.20596.564077.568365@yeti.mininet> <4779AD03.1060505@freebsd.org> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/py4gisGwkapcdZ84_msMOkv"; protocol="application/pgp-signature"; micalg=PGP-SHA1 Cc: freebsd-hackers@freebsd.org, Markus Hoenicka Subject: Re: dlopen(), atexit() crash on FreeBSD (testcase included) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jan 2008 15:40:27 -0000 --Sig_/py4gisGwkapcdZ84_msMOkv Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Mon, 31 Dec 2007 19:01:23 -0800 Tim Kientzle wrote: > Markus Hoenicka wrote: > > Alexander Kabaev writes: > > > As designed. atexit should not be used by shared objects that do > > > not expect themselves to live until actual exit() happens. ELF > > > provides proper _init/_fini sections to support shared object > > > initialization/destruction. > > >=20 > >=20 > > That is, the only real solution to this problem is to convince the > > Firebird folks to remove their atexit() calls from the client > > libraries? >=20 > I suspect they never considered that their dynamic library > might be used via dlopen()/dlclose(). The real question is > whether they're interesting in supporting this model. > If the Firebird folks aren't interested in having their > library be accessible in that fashion, then you have > little choice but to simply forgo unloading this particular > library. >=20 > It's a bit unfortunate that there is no standard way > to remove an atexit() registration. It would probably > be easier to convince the Firebird folks to remove the > registration as part of their cleanup routines (and > you could then invoke those cleanup routines manually > for that case). >=20 > > Also, I'm wondering how other OSes handle this. I don't see this > > code crash on Linux, contrary to its design as you say. >=20 > I would be curious to see the results of running your > sample program (with lots of extra fprint(stderr...) > calls, of course) on Linux to see whether it calls the > registered exit function at dlclose time or never. >=20 Linux pulls hidden atexit symbol into every binary that uses it by means of linking in libc_nonshared.a into every glibc consumer. Having local function allows for reliable determination of who has called the atexit function. Linux calls atexit entries at object unload time. Solaris implements a libc callback from ld.so.1 to cleanup dangling pointers from objects being unloaded. This resets sigaction entries, atfork and atexit callbacks. Solaris calls atexit callback when removing it too. I guess we better follow the suit, if anyone wants to that. I prefer Solaris approach myself, but see the reason for Linux one too. --=20 Alexander Kabaev --Sig_/py4gisGwkapcdZ84_msMOkv Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHel7iQ6z1jMm+XZYRApSYAKDQvld7nzJom/cJxM1aEX/EEpTEGACgtb4E htCiKwZa6bKLOSNr99KfPE0= =ziMS -----END PGP SIGNATURE----- --Sig_/py4gisGwkapcdZ84_msMOkv--