From owner-freebsd-bugs Thu Sep 19 6:30: 7 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4451F37B401 for ; Thu, 19 Sep 2002 06:30:05 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 85FE643E65 for ; Thu, 19 Sep 2002 06:30:04 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g8JDU4Co071850 for ; Thu, 19 Sep 2002 06:30:04 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g8JDU4It071849; Thu, 19 Sep 2002 06:30:04 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4AFC537B401 for ; Thu, 19 Sep 2002 06:27:46 -0700 (PDT) Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 07D9043E75 for ; Thu, 19 Sep 2002 06:27:46 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.6/8.12.6) with ESMTP id g8JDRj7R072148 for ; Thu, 19 Sep 2002 06:27:45 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.6/8.12.6/Submit) id g8JDRjlX072147; Thu, 19 Sep 2002 06:27:45 -0700 (PDT) Message-Id: <200209191327.g8JDRjlX072147@www.freebsd.org> Date: Thu, 19 Sep 2002 06:27:45 -0700 (PDT) From: Christophe Vedel To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: misc/42956: dlclose gives "invalid shared object handle" when called through the fini function of another module Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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