This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Async signal safe TLS accesses
- From: Andrew Hunter <ahh at google dot com>
- To: Rich Felker <dalias at aerifal dot cx>
- Cc: Ian Lance Taylor <iant at google dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, "Carlos O'Donell" <carlos at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>, Paul Pluzhnikov <ppluzhnikov at google dot com>
- Date: Wed, 2 Oct 2013 15:50:09 -0700
- Subject: Re: [PATCH] Async signal safe TLS accesses
- Authentication-results: sourceware.org; auth=none
- References: <523F2ED8 dot 8090909 at redhat dot com> <1379977289-21260-1-git-send-email-ahh at google dot com> <20130924025738 dot GK20515 at brightrain dot aerifal dot cx> <524C3467 dot 2030503 at redhat dot com> <Pine dot LNX dot 4 dot 64 dot 1310022203420 dot 22120 at digraph dot polyomino dot org dot uk> <CAKOQZ8wN0ecYROnxNT5edV5yxr5jiAuoLVg4ErO9DZq3SYj4HQ at mail dot gmail dot com> <20131002223612 dot GA20515 at brightrain dot aerifal dot cx>
On Wed, Oct 2, 2013 at 3:36 PM, Rich Felker <dalias@aerifal.cx> wrote:
> The idea that dlopen has to poke at all existing threads is wrong.
> That's the complex, error-prone way to implement safe TLS allocation.
> The other way is to simply allocate sufficient space (including space
> for enlarged DTVs) for the currently existing number of threads, but
> wait to give it to them until they call __tls_get_addr.
>
Note that as I understand the spec, this just doesn't work for
initial-exec TLS in dlopen'd modules. By the time dlopen returns, the
relevant relocation needs to contain an offset that has the valid
initial TLS image in all extant threads. (Remember that with
initial-exec TLS we may never get a call to tls_get_addr with which to
lazily initialize the region.) This means dlopen must iterate all
threads and fill in the correct offset with the image (as it does,
already, with or without my patch.)
One can argue that maybe dlopen should not support initial-exec but
that ship has, in fact, sailed.