[PATCH] Async signal safe TLS accesses
Andrew Hunter
ahh@google.com
Fri Jan 3 07:31:00 GMT 2014
On Thu, Jan 2, 2014 at 6:48 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> This one looks like a possible bug to me:
> it will always error if map->l_tls_offset == FORCED_DYNAMIC_TLS_OFFSET.
>
I believe this is WAI -- if I remember correctly you're quoting the
snippet invoked when we need to fulfill a TLS relocation while loading
code that assumes init-exec model for some TLS variable X. If X's
map->l_tls_offset = FORCED_DYNAMIC, that means that X was already
accessed from at least one thread, which did so in dynamic model (and
malloced an arena to hold the section). This means that thread can't
use a static TLS offset; we can't fulfill that relocation; ERROR.
(Well, we could sighandler over to each thread and move their dynamic
area to the static TLS section, but...no.)
Hence the code checks if we're FORCED_DYNAMIC and then gives up. The
code called if !FORCED will double check again when it tries to
compare_and_swap in, so I suppose it's not strictly necessary, but I
believe this is correct.
I'll double check tomorrow morning if you disagree--I'm doing this from memory.
More information about the Libc-alpha
mailing list