Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jun 2009 20:07:56 -0400
From:      Alexander Kabaev <kabaev@gmail.com>
To:        venki kaps <venkiece2005@gmail.com>
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.
Message-ID:  <20090616200756.70206fda@kan.dnsalias.net>
In-Reply-To: <6d53329e0906160229j2fdba518h84b13652153a32f6@mail.gmail.com>
References:  <6d53329e0906160229j2fdba518h84b13652153a32f6@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--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 <venkiece2005@gmail.com> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090616200756.70206fda>