public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH 3/3] nptl: Fix race between pthread_kill and thread exit (bug 12889)
Date: Thu, 19 Aug 2021 18:37:53 +0200	[thread overview]
Message-ID: <87r1epz8ym.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <88bdbb1e-2338-4fd2-0c03-89f2196ba239@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Thu, 19 Aug 2021 13:12:46 -0300")

* Adhemerval Zanella via Libc-alpha:

> On 17/08/2021 10:51, Florian Weimer via Libc-alpha wrote:
>> Thread exit is delayed until all pending pthread_kill operations
>> on the thread have completed.  This avoids sending signals to the
>> wrong thread or a spurious ESRCH error.
>> 
>> The test sysdeps/pthread/tst-pthread_cancel-select-loop.c is derived
>> from a downstream test originally written by Marek Polacek.
>
> And I really hope we could first sort out the BZ#19951 and move away
> of using pthread::tid as the synchronization member to check thread
> termination.  I sent a possible fix [1], but it does not fully handle
> the pthread::tid access, it would require to a proper lock to 
> synchronize between thread exit and pthread_kill (as Rich has suggested
> on BZ#12889).
>
> I will need to send an updated version of my pthread fixes patchset,
> since clone3 changes broke it and INVALID_TD_P needs fixing as well.
>
> [1] https://patchwork.sourceware.org/project/glibc/patch/20210610193639.3650754-5-adhemerval.zanella@linaro.org/

I think my patch is independent of the other fixes.  Its advantage over
other proposals is that it does not add waiting to pthread_kill, so
there is no signal-safety issue.

(But I probably should test if cancellation from a signal handler that
is invoked synchronously via pthread_kill still works.)

Thanks,
Florian


  reply	other threads:[~2021-08-19 16:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 13:50 [PATCH 0/3] Fix ESRCH issues in pthread_cancel, pthread_kill Florian Weimer
2021-08-17 13:50 ` [PATCH 1/3] support: Add support_wait_for_thread_exit Florian Weimer
2021-08-19 16:12   ` Adhemerval Zanella
2021-08-19 16:22     ` Florian Weimer
2021-08-17 13:51 ` [PATCH 2/3] nptl: pthread_kill, pthread_cancel should fail after exit (bug 19193) Florian Weimer
2021-08-17 13:51 ` [PATCH 3/3] nptl: Fix race between pthread_kill and thread exit (bug 12889) Florian Weimer
2021-08-19 16:12   ` Adhemerval Zanella
2021-08-19 16:37     ` Florian Weimer [this message]
2021-08-19 16:49       ` Adhemerval Zanella
2021-08-20 16:24         ` 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=87r1epz8ym.fsf@oldenburg.str.redhat.com \
    --to=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).