public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Zack Weinberg <zackw@panix.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [RFC 0/4] Make strsignal and strerror async-signal-safe
Date: Thu, 14 May 2020 13:42:05 -0300	[thread overview]
Message-ID: <836fa103-5402-5838-d556-883374201142@linaro.org> (raw)
In-Reply-To: <CAKCAbMi4=1yyhOWvDan9rdqfVuL_kg089v966NziP7pN=EGEVA@mail.gmail.com>



On 14/05/2020 12:11, Zack Weinberg wrote:
> On Thu, May 14, 2020 at 8:47 AM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>> On 14/05/2020 09:05, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>>
>>>>   2. Avoid to try translate the returned message.
>>>
>>> No more translation is a significant change.  Is this really
>>> appropriate?
>>>
>>> Using strerror output in translated strings is very common:
>>>
>>> <https://codesearch.debian.net/search?q=_%5C%28.*strerror&literal=0>
>>
>> I take that once we have proper symbols that provides the translation
>> functionality, making them async-signal-safe is an welcome improvement.
>>
>> The glibc itself uses the __sys_* access on libSegFault due this
>> shortcoming.  And I am not if other programs are really aware of
>> the shortcoming of the always translatable error strings.
> 
> I think I'm with Florian here.  There is lots of existing code that
> expects strerror() to translate, and _most_ of the time it's not being
> called from an async signal handler, making everyone change their code
> to use strerror_l (and get a locale_t to use it with) just to get back
> the behavior they're used to seems like too much churn.

Alright, I took this semantic change would to make them async-signal-safe
allow to be more beneficial in the long term (in both code complexity and
more concise API) but looks like we should go to newer symbols instead.

> 
> It would be nice if there was a way for strerror to detect that it
> wasn't safe for it to call dcgettext or allocate memory.  In principle
> we ought to be able to try-lock the "I might need to initialize the
> global locale now" lock but, looking at the guts of dcgettext, there's
> several different locks involved and it's not clear to me that we
> could make this work without a major overhaul of libintl.
> 
> (Giant-hammer idea: have sigaction wrap all signal handlers with a
> routine that sets a thread-local flag while calling the signal
> handler.  siglongjmp and swapcontext would need to restore this flag.)

The sigaction wrap was a suggestion I proposed to Florian some time ago
as a way to detect a code was running in a signal handler.  FreeBSB does
this for the its libpthread analogous and its adds some complexity 
(it uses a static list and it requires some locking to handle concurrent
access), but I think it should be feasible.

  reply	other threads:[~2020-05-14 16:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 20:26 Adhemerval Zanella
2020-05-13 20:26 ` [RFC 1/4] string: Make strsignal async-signal-safe Adhemerval Zanella
2020-05-14  7:15   ` Andreas Schwab
2020-05-13 20:26 ` [RFC 2/4] string: Add strsignal_l Adhemerval Zanella
2020-05-14  0:16   ` Joseph Myers
2020-05-13 20:26 ` [RFC 3/4] string: Make strerror async-signal-safe Adhemerval Zanella
2020-05-14  7:12   ` Andreas Schwab
2020-05-13 20:26 ` [RFC 4/4] string: Move strerror_l pointer to tls_internal.h Adhemerval Zanella
2020-05-14 12:05 ` [RFC 0/4] Make strsignal and strerror async-signal-safe Florian Weimer
2020-05-14 12:47   ` Adhemerval Zanella
2020-05-14 15:11     ` Zack Weinberg
2020-05-14 16:42       ` Adhemerval Zanella [this message]
2020-05-14 18:39       ` Florian Weimer
2020-05-14 15:16     ` Florian Weimer
2020-05-14 16:28       ` Adhemerval Zanella
2020-05-14 16:40         ` Florian Weimer
2020-05-14 16:46           ` Adhemerval Zanella
2020-05-14 16:51             ` Florian Weimer
2020-05-14 16:55               ` Adhemerval Zanella
2020-05-14 17:02                 ` Florian Weimer
2020-05-14 17:34                   ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=836fa103-5402-5838-d556-883374201142@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=zackw@panix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).