From owner-freebsd-arm@FreeBSD.ORG Wed Jun 17 00:34:26 2009 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57CDD106564A; Wed, 17 Jun 2009 00:34:26 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.221.173]) by mx1.freebsd.org (Postfix) with ESMTP id E1F928FC24; Wed, 17 Jun 2009 00:34:25 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: by qyk3 with SMTP id 3so6284815qyk.3 for ; Tue, 16 Jun 2009 17:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=kitMmyazbIZU3ynb3GuP2oKdxmgt1Meodyd1OFCnX1M=; b=COyxB9ct+Ze7Gj+WAhrDhPuidFJqfCrL1kU54ZCfW779EhjRF6UvT+CEXPPjeBtpWF 0D40YpQhTWmnpe4HtqorCTIyNaobnu1mq9FXkmzBTlhsJPeLlFBCYx98Lx0M9GDwJnI6 nrXuRVzQPZPEHdJDkvv8EOr/F6cJqYCM8ou+8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=Giis/5KOrpqBo8wsamv8AWmGRHxJbC6tLSXEcQ6eG4E5ru+BSMVdbOCZDQgZZN20sX 32DNqEGOScmWCVaJL9UMbUxc7QyEzXIq2MZVtKekhRLeSiDaQlfBpNx9PyJczvdsiDOW kGrH+3DMEWsdHMCq9GJxqu39gadqOIkQIYeZg= Received: by 10.224.29.2 with SMTP id o2mr9087890qac.102.1245197286024; Tue, 16 Jun 2009 17:08:06 -0700 (PDT) Received: from kan.dnsalias.net (c-98-217-224-113.hsd1.ma.comcast.net [98.217.224.113]) by mx.google.com with ESMTPS id 6sm223875qwd.32.2009.06.16.17.08.04 (version=SSLv3 cipher=RC4-MD5); Tue, 16 Jun 2009 17:08:05 -0700 (PDT) Date: Tue, 16 Jun 2009 20:07:56 -0400 From: Alexander Kabaev To: venki kaps Message-ID: <20090616200756.70206fda@kan.dnsalias.net> In-Reply-To: <6d53329e0906160229j2fdba518h84b13652153a32f6@mail.gmail.com> References: <6d53329e0906160229j2fdba518h84b13652153a32f6@mail.gmail.com> X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.2; i386-portbld-freebsd8.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/rwovTwY3y=_ftDqWww523R9"; protocol="application/pgp-signature" Cc: freebsd-arm@freebsd.org, freebsd-current@freebsd.org, netbsd-users@netbsd.org Subject: Re: [libc] dlclose gives "invalid shared object handle" without pthread combination. X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2009 00:34:26 -0000 --Sig_/rwovTwY3y=_ftDqWww523R9 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi, I do not think we on FreeBSD support NetBSD rtld with our pthread libraries, unless you already implemented all the necessary glue. The interface between threading library and rtld is rather intimate and tricky to get right. You provide no code to look at nor explicitly mention what OS and what version you are running your test on (FreeBSD?), I think you are on your own. Furthermore, your claim on 'correct' constructor/destructor is wrong given the sample code provided by NetBSD PR. Some more comments are inline. On Tue, 16 Jun 2009 14:59:36 +0530 venki kaps wrote: > Hi, >=20 > I am using the NetBSD implementation of rtld(src/libexec/ld.elf_so/) > for ARM/MIPS. >=20 > I have C++ static constructor/destructor issue with my rtld. >=20 > Problem Report: > "ld.elf_so does not execute .init/.fini functions in order" and [libc] > dlclose gives > "invalid shared object handle" when called through the fini function > of another module. >=20 > The similar NetBSD/freeBSD issues are found from the following > References: [1] http://gnats.netbsd.org/37347 > [2] http://updraft3.jp.freebsd.org/cgi/query-pr.cgi?pr=3Dkern/42956 >=20 > The above issues are already commited in NetBSD-5-0-RELEASE. >=20 > I have ported NetBSD-5-0-RELEASE rtld and tested Ref[1] provided > static constructor/destructor test and did not find any issues > with shared pthread combination but noticed [libc] dlclose gives > "invalid shared object handle" without pthread combination. >=20 > The static constructor/destructor test results: >=20 > It should be : > -------------- >=20 > $ ./foobar > foo_ctor > bar_ctor > tar_ctor > main_ctor > dep1_ctor > dep2_ctor > dll_ctor > dll_dtor > dep2_dtor > dep1_dtor > main_dtor > tar_dtor > bar_dtor > foo_dtor Given the test in Ref[1], both constructor and destructor orders are wrong above. libdep1 depends on libdep2, so dep2_ctor should be invoked before dep1_ctor and consequently dep2_dtor should be invoked after dep1_dtor. =20 > While currently I get: > ---------------------- >=20 > with pthreads: >=20 > $ ./foobar > foo_ctor > bar_ctor > tar_ctor > main_ctor > dep1_ctor > dep2_ctor > dll_ctor > dll_dtor > dep2_dtor > dep1_dtor > main_dtor > tar_dtor > bar_dtor > foo_dtor >=20 > without pthreads: >=20 > $ ./foobar > foo_ctor > bar_ctor > tar_ctor > main_ctor > dep1_ctor > dep2_ctor > dll_ctor > dll_dtor > dep2_dtor > dep1_dtor > main_dtor > tar_dtor > bar_dtor > foo_dtor > Invalid shared object handle 0xbdbed400 Again, given the sample code from NetBSD PR cannot possibly print this message because it never even calls dlerr(). You must be looking at some other code and unless you provide it, understanding your problem and fixing it is next to impossible. Said that, thanks for pointing the FreeBSD PR to me. I will commit the fix for the problem described here shortly. =20 > This gives a "invalid shared object handle" message > because the refcount field (obj->dl_refcount) for the handle is zero. >=20 > I have little bit confused about dlclose destructor > with/without pthreads. >=20 > I have some queries: > 1) Is it required any changes apart from the > NetBSD-5-0-RELEASE/{Ref[1],[2]}? 2) Are any changes required in > thread-stub? >=20 > Could anyone provide any inputs to the my issue? >=20 > Thanks in advance. >=20 > Thanks & Regards, > Venkappa --=20 Alexander Kabaev --Sig_/rwovTwY3y=_ftDqWww523R9 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (FreeBSD) iD8DBQFKODPhQ6z1jMm+XZYRAuCjAKC94cJ7t9l68OMZoigdjbyLNp2t5QCg4Xzh gpe/B6QrwPZFZU9lEKejMtg= =vhtp -----END PGP SIGNATURE----- --Sig_/rwovTwY3y=_ftDqWww523R9--