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 07:25:18 -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>
On Thu, Sep 19, 2013 at 9:52 PM, Carlos O'Donell <carlos@redhat.com> wrote:
>
>> On Wed, Jun 13, 2012 at 6:08 PM, Ian Lance Taylor <iant@google.com> wrote:
>>
>>> We are currently in an unpleasant situation where it is very easy and
>>> natural to use TLS variables--you just refer to them by name--and using
>>> them in a signal handler almost always works just fine. Except that in
>>> some highly specific but not completely implausible circumstances it
>>> crashes incomprehensibly. This is not a good thing, it's a lurking time
>>> bomb.
>
> I don't buy this argument. There are *lots* of lurking bombs in C and
> POSIX that can crash your application. This would be just another situation
> where we need to document that TLS is not AS-safe (add it to the list of
> non-AS-safe things that Alex is documenting in the manual).
I suppose I don't buy your counter-argument. The fact that many
features of C are difficult to use correctly is not an argument for
adding additional features that are difficult to use correctly.
Clearly it is technically infeasible to use some features from a
signal handler. I'm not going to waste time suggesting that it be
possible to call malloc from a signal handler. However, making it
safe to use __thread variables in a signal handler is not technically
infeasible. If we fail to support it, we're just being lazy.
Ian