Date: Sun, 19 Aug 2007 16:58:10 -0400 (EDT) From: "Mikhail T." <mi@aldan.algebra.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: jdp@polstra.com Subject: bin/115631: make dlclose atexit-aware (patch) Message-ID: <200708192058.l7JKwAw6016989@aldan.algebra.com> Resent-Message-ID: <200708192100.l7JL03xN034430@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708192058.l7JKwAw6016989>