From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Torvald Riegel <triegel@redhat.com>,
Carlos O'Donell <carlos@redhat.com>
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
Marcus Shawcroft <Marcus.Shawcroft@arm.com>
Subject: Re: [PATCH] pthread_once hangs when init routine throws an exception [BZ #18435]
Date: Wed, 08 Jul 2015 16:52:00 -0000 [thread overview]
Message-ID: <559D5539.5050606@arm.com> (raw)
In-Reply-To: <1436373181.22407.38.camel@localhost.localdomain>
On 08/07/15 17:33, Torvald Riegel wrote:
> On Wed, 2015-07-08 at 12:09 -0400, Carlos O'Donell wrote:
>> On 07/08/2015 07:00 AM, Szabolcs Nagy wrote:
>>> (2) Should gcc support exceptions from async signal handlers?
>>
>> No. I don't think you can support it safely.
>>
>>> nptl/tst-join5 failure is more problematic: it fails because gcc
>>> does not seem to implement -fexceptions with the assumption that
>>> signal handlers can throw, in particular it assumes inline asm
>>> does not throw exceptions. If the syscall that is a cancellation
>>> point appears between pthread_cleanup_push and pthread_cleanup_pop
>>> in glibc internal code, the cleanup handler may not get run on
>>> cancellation depending on where gcc moved the syscall inline asm.
>>> (It is free to move it outside the code range that is marked for
>>> exception handling, this is what happens on aarch64 in pthread_join).
>>> This affects all archs, but some may get lucky.
>>
>> Ah! That's truly a terrible scenario.
>>
>>> (My understanding: gcc must be very strict about how it marks
>>> the code range for exception handling and assume any instruction
>>> may throw if it wants -fexceptions -fasynchronous-unwind-tables to
>>> work from signal handlers. Current compilers do not seem to support
>>> this so glibc internal code should not rely on it, which means the
>>> cancellation mechanism should not rely on exception handling at
>>> least not when the exception is thrown from the cancel signal
>>> handler. I think the gnu toolchain should not try to make pthread
>>> cancellation to interoperate with C++ exceptions nor to make
>>> exceptions work from signal handlers: no standard requires this
>>> behaviour and seems to cause problems).
>>
>> No, we just need to revert this patch and have C++ implement
>> std::call_once by itself.
>
> Would point (2) be taken care of by Adhemerval's cancellation changes?
>
yes: if the cancel point syscall is not inline asm,
but extern call (that is not marked with nothrow)
then gcc -fexceptions should handle it correctly.
asynchronous cancellation is still problematic,
but that is a special case.
next prev parent reply other threads:[~2015-07-08 16:52 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <556B7F10.40209@redhat.com>
2015-06-01 8:39 ` Florian Weimer
2015-06-01 16:27 ` Martin Sebor
2015-06-02 9:53 ` Mike Frysinger
2015-06-04 21:12 ` Martin Sebor
2015-06-03 11:36 ` Torvald Riegel
2015-06-01 10:20 ` Szabolcs Nagy
2015-06-01 19:47 ` Martin Sebor
2015-06-03 11:07 ` Torvald Riegel
2015-06-03 11:11 ` Jonathan Wakely
2015-06-03 20:14 ` Rich Felker
2015-06-03 20:24 ` Martin Sebor
2015-06-03 23:49 ` Rich Felker
2015-06-04 1:47 ` Martin Sebor
2015-06-04 5:38 ` Rich Felker
2015-06-04 7:29 ` Martin Sebor
2015-06-08 11:41 ` Jonathan Wakely
2015-06-08 14:38 ` Szabolcs Nagy
2015-06-04 8:20 ` Torvald Riegel
2015-06-08 11:48 ` Jonathan Wakely
2015-06-08 16:01 ` Florian Weimer
2015-06-03 11:07 ` Torvald Riegel
2015-06-01 14:39 ` Andreas Schwab
2015-06-09 19:49 ` Martin Sebor
2015-06-15 22:14 ` Martin Sebor
2015-06-23 7:48 ` [PING 2] " Martin Sebor
[not found] ` <5593256B.5060402@redhat.com>
2015-07-01 0:06 ` [PING 3] " Rich Felker
2015-07-01 20:18 ` Martin Sebor
2015-07-01 21:27 ` Joseph Myers
2015-07-06 13:18 ` Szabolcs Nagy
2015-07-06 14:16 ` Martin Sebor
2015-07-06 14:58 ` Adhemerval Zanella
2015-07-06 16:33 ` Szabolcs Nagy
2015-07-06 17:09 ` Szabolcs Nagy
2015-07-08 11:00 ` Szabolcs Nagy
2015-07-08 16:09 ` Carlos O'Donell
2015-07-08 16:33 ` Torvald Riegel
2015-07-08 16:52 ` Szabolcs Nagy [this message]
2015-07-08 17:14 ` Carlos O'Donell
2021-03-02 16:43 ` Jakub Jelinek
2015-07-08 16:16 ` Carlos O'Donell
2015-07-08 21:28 ` Martin Sebor
2015-07-08 22:13 ` Szabolcs Nagy
2015-07-08 22:52 ` Martin Sebor
2015-07-08 23:42 ` Szabolcs Nagy
2015-07-09 4:46 ` Martin Sebor
2015-07-09 23:41 ` Martin Sebor
2021-03-03 12:52 Jakub Jelinek
2021-03-04 11:50 ` Florian Weimer
2021-03-04 13:00 ` Jakub Jelinek
2021-03-04 13:26 ` Florian Weimer
2021-03-04 14:14 ` Jakub Jelinek
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=559D5539.5050606@arm.com \
--to=szabolcs.nagy@arm.com \
--cc=Marcus.Shawcroft@arm.com \
--cc=adhemerval.zanella@linaro.org \
--cc=carlos@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=triegel@redhat.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).