From: Aurelien Jarno <aurelien@aurel32.net>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org, Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH] nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
Date: Fri, 8 Apr 2022 18:48:07 +0200 [thread overview]
Message-ID: <YlBnRzZ9iI4QqwxG@aurel32.net> (raw)
In-Reply-To: <20220407132602.1689442-1-adhemerval.zanella@linaro.org>
On 2022-04-07 10:26, Adhemerval Zanella 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
> ---
> manual/process.texi | 3 +-
> nptl/allocatestack.c | 2 -
> nptl/cancellation.c | 50 ++++++--
> nptl/cleanup_defer.c | 42 ++++++-
> nptl/descr.h | 33 ++++--
> nptl/libc-cleanup.c | 39 ++++++-
> nptl/pthread_cancel.c | 106 ++++++++++++-----
> nptl/pthread_join_common.c | 7 +-
> nptl/pthread_setcancelstate.c | 26 ++++-
> nptl/pthread_setcanceltype.c | 31 ++++-
> nptl/pthread_testcancel.c | 9 +-
> sysdeps/nptl/dl-tls_init_tp.c | 3 -
> sysdeps/pthread/Makefile | 1 +
> sysdeps/pthread/tst-cancel29.c | 207 +++++++++++++++++++++++++++++++++
> 14 files changed, 473 insertions(+), 86 deletions(-)
> create mode 100644 sysdeps/pthread/tst-cancel29.c
Thanks a lot for providing a fix so quickly. I confirm the patch works
as expected.
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://www.aurel32.net
next prev parent reply other threads:[~2022-04-08 16:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 13:26 Adhemerval Zanella
2022-04-08 16:48 ` Aurelien Jarno [this message]
2022-04-11 14:54 ` Florian Weimer
2022-04-14 15:49 ` Adhemerval Zanella
2022-04-14 15:55 ` Florian Weimer
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=YlBnRzZ9iI4QqwxG@aurel32.net \
--to=aurelien@aurel32.net \
--cc=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.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).