Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Oct 2006 19:47:56 -0400
From:      Alexander Kabaev <kabaev@gmail.com>
To:        John Baldwin <john@baldwin.cx>
Cc:        Takahiro <takahiro.kurosawa@gmail.com>, freebsd-gnats-submit@freebsd.org, KUROSAWA@freebsd.org, freebsd-threads@freebsd.org
Subject:   Re: threads/103975: Implicit loading/unloading of libpthread.so may crash user processes
Message-ID:  <20061005194756.07580108@kan.dnsalias.net>
In-Reply-To: <200610050906.21304.john@baldwin.cx>
References:  <200610041356.k94DuOmj097237@www.freebsd.org> <200610050906.21304.john@baldwin.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_olRQb9w73LRMGWxv5Pd0njU
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Thu, 5 Oct 2006 09:06:20 -0400
John Baldwin <john@baldwin.cx> wrote:

>=20
> Actually, I wonder if it should be allowed to unload at all.  On 4.x
> at work we ran into an issue with the linuxthreads library loading,
> setting _is_threaded, then unloading with a malloc() occurring during
> the destructors resolving a _spinlock() weak symbol, then after the
> libraries were completely unloaded, the next malloc() blew up when
> _spinlock() pointed off into space.  Hmm, this specific condition is
> handled I think since __isthreaded in 6.x libpthread isn't set until
> you do pthread_create() which at that point means a symbol is
> resolved, and the library won't be unloaded (I think).  Hmm, maybe
> not since that doesn't guarantee that libc depends on libpthread
> (that is what keeps it from being unloaded IIRC). So, maybe when the
> library sets __isthreaded it should call one of the libc functions
> (like malloc) to force one of the weak symbols to be resolved so it
> isn't unloaded.
>=20
> > To fix the problem, a function that has __attribute__((destructor))
> > in libpthread should probably be implemented in order to recover
> > the initial state before unloading.
>=20
> I'm not sure you can recover the state actually, hence why I think
> maybe we should make it so that libpthread doesn't unload once it has
> been loaded.
>=20
> --=20
> John Baldwin

Linux does not allow pthread library to be unloaded presumably because
of reasons like this. From readelf -a /compat/linux/lib/libpthread.so.0:

 0x6ffffffb (FLAGS_1)                    Flags: NODELETE INITFIRST

Infortunately, rtld does not implement NODELETE and INITFIRST. Both are
addressed in my patch that I am yet to commit.


--=20
Alexander Kabaev

--Sig_olRQb9w73LRMGWxv5Pd0njU
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFJZmvQ6z1jMm+XZYRAkaKAJ9/bV9FU6UgIVbE7QZAhBLKD7rg5ACeMjGr
1DVtUSKdDtw5N2PFrbduuwc=
=+av7
-----END PGP SIGNATURE-----

--Sig_olRQb9w73LRMGWxv5Pd0njU--



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