unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: libc-alpha@sourceware.org
Subject: Re: Async cacellation and pthread_cleanup_push
Date: Mon, 23 Aug 2021 12:11:33 +0200	[thread overview]
Message-ID: <87h7fgqxm2.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <87mtp8scga.fsf@igel.home> (Andreas Schwab's message of "Mon, 23 Aug 2021 12:05:41 +0200")

* Andreas Schwab:

> On Aug 23 2021, Florian Weimer wrote:
>
>> * Andreas Schwab:
>>
>>> On Aug 04 2021, Florian Weimer wrote:
>>>
>>>> * Andreas Schwab:
>>>>
>>>>> On Aug 04 2021, Florian Weimer wrote:
>>>>>
>>>>>> * Andreas Schwab:
>>>>>>
>>>>>>> Is pthread_cleanup_push supposed to work together with async
>>>>>>> cancellation?
>>>>>>
>>>>>> In our implementation?  I think so.
>>>>>
>>>>> I don't see how that can work with -fexceptions or in C++, though.  Is
>>>>> that supported?
>>>>
>>>> I think it is supposed to work, but it probably is unreliable.
>>>
>>> Since the compiler puts the exception regions only over function calls
>>> (and -fnon-call-exceptions only covers potentially trapping insns in
>>> addition) the cleanup region will not be fully covered.
>>
>> I can see how this can happen in theory …
>
> This is not theory, it happens exactly here.
>
>>> testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-1.c
>>
>> … but I don't see how this applies to this particular test.
>
> There is a non-zero probability that the cancel signal arrives in
> thread_func and sleep_loop while it is executing the unprotected
> instructions outside of the .LEHB1 to .LEHE1 region:
>
>         movl    $sem, %edi
>         call    sem_post
>         movq    $0, (%rsp)
>         movq    $1000000, 8(%rsp)
>         .p2align 4,,10
>         .p2align 3
> .L2:
>         xorl    %esi, %esi
>         movq    %rsp, %rdi
> .LEHB1:
>         call    nanosleep
>         subl    $1, %ebx
>         jne     .L2
>         movl    $.LC0, %edi
>         call    puts
> .LEHE1:

Odd.

Does this happen because sem_post is annotated with __THROWNL?

GCC should ignore __attribute__ ((nothrow)) with -fnon-call-exceptions.

Thanks,
Florian


  reply	other threads:[~2021-08-23 10:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 13:58 Async cacellation and pthread_cleanup_push Andreas Schwab
2021-08-04 15:33 ` Florian Weimer via Libc-alpha
2021-08-04 16:04   ` Andreas Schwab
2021-08-04 16:10     ` Florian Weimer via Libc-alpha
2021-08-04 16:24       ` Andreas Schwab
2021-08-23  9:43         ` Florian Weimer via Libc-alpha
2021-08-23 10:05           ` Andreas Schwab
2021-08-23 10:11             ` Florian Weimer via Libc-alpha [this message]
2021-08-23 10:24               ` Andreas Schwab
2021-08-23 10:58                 ` Florian Weimer via Libc-alpha
2021-08-05 10:43       ` Petr Vorel
2021-08-06  5:25   ` Petr Vorel
2021-08-23  9:38     ` Florian Weimer via Libc-alpha
2021-08-23  9:49       ` Petr Vorel
2021-08-04 18:43 ` Zack Weinberg via Libc-alpha

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=87h7fgqxm2.fsf@oldenburg.str.redhat.com \
    --to=libc-alpha@sourceware.org \
    --cc=fweimer@redhat.com \
    --cc=schwab@linux-m68k.org \
    /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).