public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Carlos O'Donell <carlos@redhat.com>, libc-alpha@sourceware.org
Cc: Andreas Schwab <schwab@suse.de>
Subject: Re: [PATCH v3] debug: test for more required cacellation points (BZ# 29274)
Date: Tue, 26 Jul 2022 16:10:51 -0300	[thread overview]
Message-ID: <34df3473-a456-97ae-99f8-471536b0d95d@linaro.org> (raw)
In-Reply-To: <2972abfa-dfa7-c093-3c5d-9f73f0ff3983@redhat.com>



On 21/07/22 18:23, Carlos O'Donell wrote:
> On 7/18/22 12:46, Adhemerval Zanella wrote:
>> +
>> +  /* This test is the early cancel version of the first test, and the intent
>> +     is to have the cancellation happen at one of two regions:
>> +
>> +     1. Before the cancellable syscall registers cancellation.
>> +     2. After the cancellable syscall registers cancellation.
>> +
>> +     This test will exercise if syscall cancellation registration is an atomic
>> +     operation or not since the transition from the regions is designed to be
>> +     atomic.
>> +
>> +     We can not control when the cancellation happens, but it will happen in
>> +     one of the two regions.  The first test (the !only_early version)
>> +     attempts to test the second region, while this test attempts to test the
>> +     first regiont and the transition with some probability.  */
>> +  for (int i = 0; i < array_length (tests); i++)
>> +    {
>> +      xpthread_barrier_init (&barrier, NULL, 2);
>> +      /* Reset the counter for the cleanup handler.  */
>> +      cl_called = 0;
>> +
>> +      /* After this wait the cancellation handler is in place.  */
>> +      pthread_t thr = xpthread_create (0, tests[i].tf, NULL);
>> +
>> +      xpthread_cancel (thr);
>> +      xpthread_barrier_wait (&barrier);
> 
> Shouldn't this be:
> 
> xpthread_barrier_wait (&barrier);
> xpthread_cancel (thr);
> 
> You want to:
> 
> (a) Make sure a cancellation handler is registered.
> (b) Deliver the signal *before* you reach the syscall __pthread_enable_asyncancel.
> (c) Observe the cancelled bit early and act upon it.
> 
> The test is effectively very similar to the first test but with no wait to allow
> the thread to get to and block on the syscall.
> 
In fact the ordering is correct because in this case there is no signal 
involved, pthread_cancel will just mask the thread canceled 
(CANCELING_BITMASK | CANCELED_BITMASK) since asynchronous mode is not set. 

Otherwise, pthread_cancel might be called when __pthread_enable_asyncancel
is already called (changing the mode to asynchronous), and the the signal
handler it will act, not __pthread_enable_asyncancel.

  reply	other threads:[~2022-07-26 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 16:46 Adhemerval Zanella
2022-07-21 21:23 ` Carlos O'Donell
2022-07-26 19:10   ` Adhemerval Zanella Netto [this message]
2022-08-29 14:02     ` Carlos O'Donell

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=34df3473-a456-97ae-99f8-471536b0d95d@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=carlos@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    /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).