From owner-freebsd-bugs@FreeBSD.ORG Sun Aug 19 21:00:04 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 979B016A419 for ; Sun, 19 Aug 2007 21:00:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 600D613C46B for ; Sun, 19 Aug 2007 21:00:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l7JL045O034437 for ; Sun, 19 Aug 2007 21:00:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l7JL03xN034430; Sun, 19 Aug 2007 21:00:03 GMT (envelope-from gnats) Resent-Date: Sun, 19 Aug 2007 21:00:03 GMT Resent-Message-Id: <200708192100.l7JL03xN034430@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Mikhail T." Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B42B16A469 for ; Sun, 19 Aug 2007 20:58:12 +0000 (UTC) (envelope-from mi@aldan.algebra.com) Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by mx1.freebsd.org (Postfix) with ESMTP id 1780B13C474 for ; Sun, 19 Aug 2007 20:58:11 +0000 (UTC) (envelope-from mi@aldan.algebra.com) Received: from aldan.algebra.com (localhost [127.0.0.1]) by aldan.algebra.com (8.14.1/8.14.1) with ESMTP id l7JKwBbg016990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 19 Aug 2007 16:58:11 -0400 (EDT) (envelope-from mi@aldan.algebra.com) Received: (from mi@localhost) by aldan.algebra.com (8.14.1/8.14.1/Submit) id l7JKwAw6016989; Sun, 19 Aug 2007 16:58:10 -0400 (EDT) (envelope-from mi) Message-Id: <200708192058.l7JKwAw6016989@aldan.algebra.com> Date: Sun, 19 Aug 2007 16:58:10 -0400 (EDT) From: "Mikhail T." To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: jdp@polstra.com Subject: bin/115631: make dlclose atexit-aware (patch) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Aug 2007 21:00:04 -0000 >Number: 115631 >Category: bin >Synopsis: make dlclose atexit-aware (patch) >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Aug 19 21:00:03 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Mikhail T. >Release: FreeBSD 6.2-STABLE amd64 >Organization: Virtual Estates, Inc. >Environment: System: FreeBSD 6.2-STABLE >Description: Currently, an application can shoot itself in the tail by registering a symbol with atexit and then dlclose-ing the library, which provides the symbol. Programs aren't supposed to that, but sometimes they do -- most notably ImageMagick, which dlopens libjasper, which registers its own clean-up routine with atexit. The proposed patch will make such bugs easier to diagnose -- the ImageMagick problem (crash upon exiting) was mystifying people for years... >How-To-Repeat: >Fix: The up-to-date version of the patch can be found here: http://aldan.algebra.com/~mi/dlclose-atexit.patch It exposes the __atexit pointer defined in atexit.c and its type and modifies dlclose to scan through all listed functions looking for those, that belong to the object being dlclosed. The method to check whether a symbol belongs to an object is to check, whether the address is between mapbase and mapbase+mapsize of the entry. What could be improved is the addition of a an addr_to_name lookup -- to print the _name_ of the function found to be registered with atexit, rather than merely the function's address. >Release-Note: >Audit-Trail: >Unformatted: