Re: [patch] threading fix, tid-2.5.47-A3

From: Ulrich Drepper (drepper@redhat.com)
Date: Sun Nov 17 2002 - 22:40:54 EST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jamie Lokier wrote:

> The race condition which Ulrich brought up, which requires
> CLONE_CHILD_SETTID to be used without CLONE_PARENT_SETTID, only occurs
> when using the same address to store the tid of the forked child as
> the parent's tid address. In other words, it's a user space error.
> (Please correct me if I'm mistaken, Ulrich).

It's not an error. It the very basic concept of always having a correct
thread descriptor. A process created with fork() from an MT app is
different from one created with fork() from a single threaded app. In
the latter case the thread descriptors are not used and can contain
garbage. In the former case the descriptor better be correct all the
time. It basically the same problem as with setting the TLS "register".
 clone() get the CLONE_TLS flag because the child and parent have
(potentially) different TLS address and it is not possible to set the
value before the fork() call (since the parent would have the wrong
value for some time) nor after the fork() (since then there would be a
window for a signal to arrive for an uninitialized thread).

> Finally, it would be kinder to everyone if CLONE_SETTID stored the
> child's tid in _both_ the parent and child address spaces, atomically
> w.r.t. debuggers.

Yes, but then clone still has to get two addresses. In case of the
fork() implementation the parent's TID value must not be overwritten
while the child's TID value is at exactly the same virtual address as
the value in the parent. I've no problem with requiring the value
always to be written (the pointer can be to a scratch object) but there
must be two pointer parameters for that.

- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE92GFG2ijCOnn/RHQRAjQSAKCIRuhc1wgZy1PFS+waFapXRYqGjACgt6Bn
T2uKMpj7gHJedPzXxQ5EjoM=
=0C7c
-----END PGP SIGNATURE-----

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Nov 23 2002 - 22:00:20 EST