public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: libc-alpha@sourceware.org, Florian Weimer <fweimer@redhat.com>,
	Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [PATCH v2] nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
Date: Tue, 19 Apr 2022 09:23:12 -0300	[thread overview]
Message-ID: <2090662e-06e3-8202-2e50-f37d9b28586c@linaro.org> (raw)
In-Reply-To: <b47bdb60-1899-c2c4-2d08-dd292e6d064e@linaro.org>



On 19/04/2022 09:18, Adhemerval Zanella wrote:
> 
> 
> On 19/04/2022 07:44, Szabolcs Nagy wrote:
>> The 04/14/2022 12:49, Adhemerval Zanella via Libc-alpha wrote:
>>> Some Linux interfaces never restart after being interrupted by a signal
>>> handler, regardless of the use of SA_RESTART [1].  It means that for
>>> pthread cancellation, if the target thread disables cancellation with
>>> pthread_setcancelstate and calls such interfaces (like poll or select),
>>> it should not see spurious EINTR failures due the internal SIGCANCEL.
>>>
>>> However recent changes made pthread_cancel to always sent the internal
>>> signal, regardless of the target thread cancellation status or type.
>>> To fix it, the previous semantic is restored, where the cancel signal
>>> is only sent if the target thread has cancelation enabled in
>>> asynchronous mode.
>>>
>>> The cancel state and cancel type is moved back to cancelhandling
>>> and atomic operation are used to synchronize between threads.  The
>>> patch essentially revert the following commits:
>>>
>>>   8c1c0aae20 nptl: Move cancel type out of cancelhandling
>>>   2b51742531 nptl: Move cancel state out of cancelhandling
>>>   26cfbb7162 nptl: Remove CANCELING_BITMASK
>>>
>>> However I changed the atomic operation to follow the internal C11
>>> semantic and removed the MACRO usage, it simplifies a bit the
>>> resulting code (and removes another usage of the old atomic macros).
>>>
>>> Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
>>> and powerpc64-linux-gnu.
>>>
>>> [1] https://man7.org/linux/man-pages/man7/signal.7.html
>>>
>>> Reviewed-by: Florian Weimer <fweimer@redhat.com>
>>> Tested-by: Aurelien Jarno <aurelien@aurel32.net>
>>> ---
>>> v2: Fixed some typos and extended pthread_cancel comments.
>>
>>
>> since this commit various cancel tests fail for me (unreliably)
>> on aarch64 e.g. failures from 2 different test runs:
>>
>> FAIL: nptl/tst-cancel17
>> FAIL: nptl/tst-cancelx5
>> FAIL: nptl/tst-cond7
>> FAIL: nptl/tst-pthread-raise-blocked-self
>> FAIL: nptl/tst-pthread_cancel-select-loop
>>
>> FAIL: nptl/tst-cancelx20
>> FAIL: nptl/tst-cond7
>> FAIL: nptl/tst-cond8
>> FAIL: nptl/tst-join12
>> FAIL: nptl/tst-key3
>> FAIL: nptl/tst-pthread_cancel-select-loop
>>
>> an example run of nptl/tst-cond7
>>
>> $ elf/ld.so --library-path . nptl/tst-cond7 --direct
>> round 0
>> child created
>> parent: joining now
>> round 1
>> child created
>> parent: joining now
>> round 2
>> child created
>> parent: joining now
>> round 3
>> child created
>> parent: joining now
>> round 4
>> child created
>> parent: joining now
>>
>> where it is blocked forever: it seems pthread_cancel returns without
>> sending a signal (__pthread_kill_internal is not called) so join hangs.
>>
> 
> But the signal should be only sent if thread is is cancelled and has
> async cancellation enabled, which is not the case for the tests. 

Scratch that, I keep forgetting about __pthread_enable_asynccancel....

  reply	other threads:[~2022-04-19 12:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 15:49 Adhemerval Zanella
2022-04-14 18:26 ` Adhemerval Zanella
2022-04-19 10:44 ` Szabolcs Nagy
2022-04-19 12:18   ` Adhemerval Zanella
2022-04-19 12:23     ` Adhemerval Zanella [this message]
2022-04-19 12:10 ` Szabolcs Nagy
2022-04-19 12:30   ` Adhemerval Zanella
2022-04-19 12:46     ` Szabolcs Nagy
2022-04-19 13:12       ` Adhemerval Zanella
2022-07-12 21:27 ` Noah Goldstein
2022-07-12 21:28   ` Noah Goldstein
2022-07-13 12:57   ` Adhemerval Zanella Netto

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=2090662e-06e3-8202-2e50-f37d9b28586c@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.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).