From: Florian Weimer <fweimer@redhat.com>
To: Zack Weinberg <zackw@panix.com>
Cc: Stefan Liebler <stli@linux.ibm.com>,
"Carlos O'Donell" <carlos@redhat.com>,
libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Speedup various nptl/tst-cancel20 and nptl/tst-cancel21 tests.
Date: Fri, 20 Sep 2019 17:50:11 +0200 [thread overview]
Message-ID: <87zhizezm4.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <CAKCAbMiittDqLwC-T_k6kP=2PiNvw6K0JdmEiL0MGbfKuPSAMg@mail.gmail.com> (Zack Weinberg's message of "Fri, 20 Sep 2019 11:17:04 -0400")
* Zack Weinberg:
> On Fri, Sep 20, 2019 at 8:59 AM Stefan Liebler <stli@linux.ibm.com> wrote:
> ...
>> I've tried to just remove the sleeps. This works fine with tst-cancel20.
>> But with tst-cancelx20 (same code as tst-cancel20.c but compiled with
>> -fexceptions -fasynchronous-unwind-tables) it sometimes fails with:
>> called cleanups 124 => cleanup-handler in tf_body was not called.
>>
>> In the "good" case, SIGHUP is received while tf_body is blocking in read.
>> In the "error" case, SIGHUP is received while tf_body is waiting in
>> pthread_barrier_wait.
>> (This occures on s390x in the same way as on e.g. x86_64; I've used gcc
>> version 9.1.1)
> ...
>> According to the .gcc_except_table, the region with our cleanup-handler
>> starts - after pthread_barrier_wait - directly before the read call,
>> even though pthread_barrier_wait is within pthread_cleanup_push / pop:
> ...
>> Is this behaviour intended?
>>
>> The difference between those calls is "nothrow":
>> extern ssize_t read (int __fd, void *__buf, size_t __nbytes) ;
>> vs
>> extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
>> __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
>
> This looks like GCC is assuming it can hoist a call to a nothrow
> function out of a cleanup region that lexically contains it. That's
> not true when an exception can be thrown by a signal handler. I can
> see an argument that this is an incorrect optimization when
> -fasynchronous-unwind-tables is in use, but the documentation makes it
> sound like -fasynchronous-unwind-tables is only intended to enable
> *stack tracing* from an arbitrary instruction, not exceptions.
> (See the documentation for -fnon-call-exceptions as well as for
> -fasynchronous-exception-tables.)
I would have expected this to be controlled by -fnon-call-exceptions,
but the GCC 8 documentation says this:
| '-fnon-call-exceptions'
| Generate code that allows trapping instructions to throw
| exceptions. Note that this requires platform-specific runtime
| support that does not exist everywhere. Moreover, it only allows
| _trapping_ instructions to throw exceptions, i.e. memory references
| or floating-point instructions. It does not allow exceptions to be
| thrown from arbitrary signal handlers such as 'SIGALRM'.
So it does not seem to be what we are looking for.
Anyway, based on the posted analysis, the tst-cancelx20 test case is
invalid.
Thanks,
Florian
next prev parent reply other threads:[~2019-09-20 15:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 12:15 [PATCH] Speedup various nptl/tst-cancel20 and nptl/tst-cancel21 tests Stefan Liebler
2019-09-12 14:07 ` Carlos O'Donell
2019-09-20 12:59 ` Stefan Liebler
2019-09-20 15:17 ` Zack Weinberg
2019-09-20 15:50 ` Florian Weimer [this message]
2019-10-29 15:46 ` Stefan Liebler
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zhizezm4.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=carlos@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=stli@linux.ibm.com \
--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).