From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 31 23:06:14 2007 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 DA60016A479 for ; Mon, 31 Dec 2007 23:06:14 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.245]) by mx1.freebsd.org (Postfix) with ESMTP id 776D213C469 for ; Mon, 31 Dec 2007 23:06:14 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: by an-out-0708.google.com with SMTP id c14so1007454anc.13 for ; Mon, 31 Dec 2007 15:06:13 -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=JYgISVvQ9+GJ0BObwtMFi75WPDRXw671YCZIHSJl/Zc=; b=YBVe2w9lj3cyenPk3x6ucjo4WqKC3Rp4MMs8bO3yvOqLAW0QRCPtgSN60BkKZPpJXHYbwITH/4IGgmugqc7wPaFqjq9TM6OXB5/b+w+tKRT28Y+zRPi2Qv1gVuQyKhNpfZwJ+AsVcg+UYjlIBTdzLxlf6nXXTZOjvkSe6wVDh1Q= 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=rFdycBk/2kFv7kljgGzlrSqJqcL5qceOZQ8os56rhiSFdlRAel6lc8HPd/xZV8X2DIN0xabd7qMDBLNk2M+bV7gw1QFBwplNBWnkvTTTDdThze9yFwCGpXGUd39dbBCCvRw8LU6WhId7sR8o+PPONpFwttBd/1OaW4AqXewo80U= Received: by 10.100.249.9 with SMTP id w9mr26822930anh.105.1199142373721; Mon, 31 Dec 2007 15:06:13 -0800 (PST) Received: from kan.dnsalias.net ( [24.218.183.247]) by mx.google.com with ESMTPS id a42sm16609753rne.11.2007.12.31.15.06.12 (version=SSLv3 cipher=OTHER); Mon, 31 Dec 2007 15:06:12 -0800 (PST) Date: Mon, 31 Dec 2007 18:06:05 -0500 From: Alexander Kabaev To: Julian Elischer Message-ID: <20071231180605.1fb939a9@kan.dnsalias.net> In-Reply-To: <47796B43.9050704@elischer.org> References: <18297.6718.750894.937199@yeti.mininet> <20071231142620.39f2fbd2@kan.dnsalias.net> <18297.20596.564077.568365@yeti.mininet> <47796B43.9050704@elischer.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_/GxjZ=1Wx=Y9c_dyXrLIsawV"; 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: Mon, 31 Dec 2007 23:06:14 -0000 --Sig_/GxjZ=1Wx=Y9c_dyXrLIsawV Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Mon, 31 Dec 2007 14:20:51 -0800 Julian Elischer 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? I'll try, but I'm not very confident this is going to > > work. 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 > > Thanks anyway to you, and to Jason Evans, for your replies. >=20 > Not sure but I'd guess that each library calls its at_exit entrypoints > as part of its unload handling. >=20 This is not possible in general case. The object that calls atexit() is not necessarily object that contains clean-up routine, so when atexit() is to be called: when object that contains the routine itself is being unloaded or when the object that registered it goes away? Also, calling atexit hooks at that time is semantically wrong for atexit() as it is defined, dlclose(3) is NOT exit(2). C++ ABI defines a special __cxa_atexit function that does have proper semantics to work around atexit() deficiencies. We can hack rtld/libc to pull dangling atexit off the list entries when shared objects are being unloaded or to add extra references to libraries pointed to by atexit entries, but that will just paper over the general issue of Firebird (and like) folks using the API improperly. --=20 Alexander Kabaev --Sig_/GxjZ=1Wx=Y9c_dyXrLIsawV Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHeXXdQ6z1jMm+XZYRAseDAJ9V8uuZ7O6k+Fz9RpaGB0ZKMZ6nbQCcDy9X PluFdI27c2S0HY6dcmgk+mc= =qkx9 -----END PGP SIGNATURE----- --Sig_/GxjZ=1Wx=Y9c_dyXrLIsawV--