Date: Thu, 19 Sep 2002 06:27:45 -0700 (PDT) From: Christophe Vedel <cv@validy.com> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/42956: dlclose gives "invalid shared object handle" when called through the fini function of another module Message-ID: <200209191327.g8JDRjlX072147@www.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 42956 >Category: misc >Synopsis: dlclose gives "invalid shared object handle" when called through the fini function of another module >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Sep 19 06:30:03 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Christophe Vedel >Release: 4.6-RELEASE >Organization: Validy >Environment: FreeBSD freebsd46.home.org 4.6-RELEASE FreeBSD 4.6-RELEASE #0: Tue Jun 11 06:14:12 GMT 2002 murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC i386 >Description: Dlopened ELF module A dlopens ELF module B and keeps a handle to it in a static C++ object. When the process exits, rtld_exit is called and the fini function for A is called. This function calls the object static destructor and it tries to dlclose the handle to B. This gives a "invalid shared object handle" message because the refcount field for the handle is zero. All refcount fields have been set to zero in rtld_exit so that objlist_call_fini calls all fini functions. >How-To-Repeat: dlclose a valid shared object handle from the fini function of another dynamically loaded shared object >Fix: possible fix: in libebxec/rtld-elf/rtld.c, add a "force" parameter to objlist_call_fini to be able to force the calls to fini even when refcount is not zero. In rtld_exit, do not zero the refcount fields, instead set the force parameter to one when calling objlist_call_fini. In dlclose, set the force parameter to zero. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209191327.g8JDRjlX072147>