This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Speedup various nptl/tst-cancel20 and nptl/tst-cancel21 tests.
* Zack Weinberg:
> On Fri, Sep 20, 2019 at 8:59 AM Stefan Liebler <firstname.lastname@example.org> 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
>> (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) ;
>> 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
I would have expected this to be controlled by -fnon-call-exceptions,
but the GCC 8 documentation says this:
| 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