From owner-freebsd-arch Fri Dec 6 15:21:56 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DA0F337B401 for ; Fri, 6 Dec 2002 15:21:54 -0800 (PST) Received: from corbulon.video-collage.com (corbulon.video-collage.com [64.35.99.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id 468C743E9C for ; Fri, 6 Dec 2002 15:21:54 -0800 (PST) (envelope-from mi@corbulon.video-collage.com) Received: from corbulon.video-collage.com (localhost.video-collage.com [127.0.0.1]) by corbulon.video-collage.com (8.12.6/8.12.6) with ESMTP id gB6NLdjJ052453 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Fri, 6 Dec 2002 18:21:39 -0500 (EST) (envelope-from mi@corbulon.video-collage.com) Received: (from mi@localhost) by corbulon.video-collage.com (8.12.6/8.12.6/Submit) id gB6NLcEt052452; Fri, 6 Dec 2002 18:21:38 -0500 (EST) (envelope-from mi) From: Mikhail Teterin Message-Id: <200212062321.gB6NLcEt052452@corbulon.video-collage.com> Subject: atexit(3), exit(3) vs. dlclose(3) et al To: arch@FreeBSD.org Date: Fri, 6 Dec 2002 18:21:38 -0500 (EST) Cc: riggs@rrr.de X-Mailer: ELM [version 2.4ME+ PL92b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Scanned-By: MIMEDefang 2.21 (www . roaringpenguin . com / mimedefang) Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hello! I've just reported what seems to be a bug in mplayer, but am still wondering, why it existed for so long. Mplayer was crashing in exit(3) (a silly place to crash, is not it?). Turns out, it dlopen(3)s some "back end" libraries, which may call atexit(3) to register their own callbacks, which remain registered even after the libraries themselves were dlclose(3)d. This usually causes the crash when exit(3) tries to call the callbacks one at a time... Don't call dlclose(3)? Kind of unclean... Why does it even exist -- even after a simple dlopen(3) a library's _init() can call atexit(3), and you will die exit(3)ing. There is no standard way to even query the __atexit list... May be, the dlopen/dlclose should monitor the atexit calls and arrange for the functions to be called at dlclose OR exit time -- whichever comes first? Or simply bump the reference count of the library to which the function being registered belongs? But they would have to distinguish the functions in the library being dlclosed from others, in order to not change the semantics... Why didn't the mplayer's authors notice until now? They develop on Linux, is Linux' handling of these functions substantially different? Ouch... Any comments? -mi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message