This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Async-signal-safe access to __thread variables from dlopen()ed libraries?
- From: Ian Lance Taylor <iant at google dot com>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: Paul Pluzhnikov <ppluzhnikov at google dot com>, Roland McGrath <roland at hack dot frob dot com>, Richard Henderson <rth at twiddle dot net>, GNU C Library <libc-alpha at sourceware dot org>, Andrew Hunter <ahh at google dot com>, Alexandre Oliva <aoliva at redhat dot com>
- Date: Fri, 20 Sep 2013 14:28:46 -0700
- Subject: Re: Async-signal-safe access to __thread variables from dlopen()ed libraries?
- Authentication-results: sourceware.org; auth=none
- References: <20120612193224 dot 8E43619060E at elbrus2 dot mtv dot corp dot google dot com> <4FD8D974 dot 7090903 at twiddle dot net> <20120613182826 dot 0CFAB2C0A3 at topped-with-meat dot com> <CALoOobMtXCw+oe7ZL0=my8YH5st8b1==CasS8i07z6G9DfaX-w at mail dot gmail dot com> <20120613210444 dot 659732C095 at topped-with-meat dot com> <mcr4nqebzok dot fsf at dhcp-172-18-216-180 dot mtv dot corp dot google dot com> <20120614002931 dot ABB762C08B at topped-with-meat dot com> <mcr1uliaeep dot fsf at dhcp-172-18-216-180 dot mtv dot corp dot google dot com> <CALoOobPJ7G7ciRfc2JwzHjsDTg4-_h-SXqeU1zR4WEzoyQhyNg at mail dot gmail dot com> <523BD470 dot 6090203 at redhat dot com> <CAKOQZ8y85QBkd97cEEmP-4OgE2KizCqknrVR_n44pwBGMs5uAw at mail dot gmail dot com> <523C88D1 dot 6090304 at redhat dot com> <CAKOQZ8ze1zKdQRsMsmBCqnJr361Gvv8mYjLjGgzYwWJEKUY+7w at mail dot gmail dot com> <523CB72A dot 7040507 at redhat dot com>
On Fri, Sep 20, 2013 at 1:59 PM, Carlos O'Donell <carlos@redhat.com> wrote:
>
> I've started a wiki page and I'll summarize people's comments there:
> https://sourceware.org/glibc/wiki/TLSandSignals
I tried to edit the page but I evidently don't have permissions (I
just created an account on the wiki IanLanceTaylor).
I don't think you characterized the problem precisely. The issue is
not receiving a signal while the thread is initializing TLS. The
general issue is that calling __tls_get_addr can call malloc, which is
not async-signal-safe. A specific example would be
* There is an existing thread.
* The program does a dlopen of a shared library that uses TLS.
* The shared library installs a signal handler that refers to a TLS variable.
* The signal handler is called on the existing thread.
* Because shared library TLS variables are installed lazily, the
existing thread does not yet have a copy of the TLS variable.
* Therefore the signal handlers TLS reference calls malloc.
* If the signal occurred during a call to malloc, we have a deadlock.
Ian