unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org
Cc: Florian Weimer <fweimer@redhat.com>
Subject: [PATCH v2 00/19] Fix various NPTL synchronization issues
Date: Mon, 23 Aug 2021 16:50:28 -0300	[thread overview]
Message-ID: <20210823195047.543237-1-adhemerval.zanella@linaro.org> (raw)

This is an update of my previous set to fix some NPTL issues [1].
The main changes are:

  - Rebased against master and adjusted the __clone_internal usage.
  - Adapted Florian's ESRCH fixes [2]
  - Add fixes for various function that access the 'tid'.

Patch 01 to 03 are general nptl fixes and they are independent of the
other fixes.

Patch 04 is the main change of this patchset, it uses a different
field instead of the pthread 'tid' to synchrnonize the internal
thread state (BZ#19951).

It allows to both move the thread setxid internal state out of
'cancelhandling' (used on setuid() call in multi-thread information),
and remove the EXITING_BIT and TERMINATED_BIT (since 'joinstate' now
track such it).  This is done on patch 05 and 06.

Patches 08 and 09 fixes two long standing issues regarding
pthread_kill() and thread exit (BZ#12889 and BZ#19193).  Now that]
'tid' is setting explicitly by pthread_create(), a simple lock can be
used instead of more complex futex operation.

Patches 10 to 18 extend the same 'tid' access fix to other pthread
functions that uses the member.

[1] https://patchwork.sourceware.org/project/glibc/list/?series=2304
[2] https://patchwork.sourceware.org/project/glibc/list/?series=2696

Adhemerval Zanella (16):
  nptl: Fix tst-cancel7 and tst-cancelx7 race condition (BZ #14232)
  nptl: Set cancellation type and state on pthread_exit
  nptl: Handle robust PI mutexes for !__ASSUME_SET_ROBUST_LIST
  nptl: Do not use pthread set_tid_address as state synchronization (BZ
    #19951)
  nptl: Move setxid flag out of cancelhandling
  nptl: Replace struct thread cancelhandling field
  nptl: Use tidlock when accessing TID on pthread_getaffinity_np
  nptl: Use tidlock when accessing TID on pthread_setaffinity
  nptl: Use tidlock when accessing TID on pthread_getcpuclockid
  nptl: Use tidlock when accessing TID on pthread_getschedparam
  nptl: Use tidlock when accessing TID on pthread_setschedparam
  nptl: Use tidlock when accessing TID on pthread_getname_np
  nptl: Use tidlock when accessing TID on pthread_setname_np
  nptl: Use tidlock when accessing TID on pthread_sigqueue
  nptl: Use tidlock when accessing TID on pthread_setschedprio
  nptl: Remove INVALID_TD_P

Florian Weimer (3):
  support: Add support_wait_for_thread_exit
  nptl: pthread_kill, pthread_cancel should fail after exit (bug 19193)
  nptl: Fix race between pthread_kill and thread exit (bug 12889)

 nptl/Makefile                                 |   3 +-
 nptl/Versions                                 |   1 +
 nptl/allocatestack.c                          |   6 +-
 nptl/cancellation.c                           |  17 +-
 nptl/descr.h                                  |  48 +++---
 nptl/nptl-stack.h                             |   2 +-
 nptl/nptl_free_tcb.c                          |  22 +--
 nptl/nptl_setxid.c                            |  49 ++----
 nptl/pthread_cancel.c                         |  20 +--
 nptl/pthread_clockjoin.c                      |   2 +-
 nptl/pthread_create.c                         | 124 ++++++++------
 nptl/pthread_detach.c                         |  36 ++--
 nptl/pthread_exit.c                           |   4 +-
 nptl/pthread_getaffinity.c                    |  22 ++-
 nptl/pthread_getattr_np.c                     |   2 +-
 nptl/pthread_getcpuclockid.c                  |  27 +--
 nptl/pthread_getname.c                        |  45 +++--
 nptl/pthread_getschedparam.c                  |  16 +-
 nptl/pthread_join.c                           |   2 +-
 nptl/pthread_join_common.c                    | 126 +++++---------
 nptl/pthread_kill.c                           |  21 ++-
 nptl/pthread_setaffinity.c                    |  22 ++-
 nptl/pthread_setname.c                        |  34 ++--
 nptl/pthread_setschedparam.c                  |  16 +-
 nptl/pthread_setschedprio.c                   |  17 +-
 nptl/pthread_sigqueue.c                       |  52 +++---
 nptl/pthread_testcancel.c                     |  11 +-
 nptl/pthread_timedjoin.c                      |   2 +-
 nptl/pthread_tryjoin.c                        |  18 +-
 nptl/tst-cancel7.c                            | 114 ++++++-------
 nptl/tst-cleanup5.c                           | 157 ++++++++++++++++++
 nptl_db/structs.def                           |   2 +-
 nptl_db/td_thr_get_info.c                     |  16 +-
 nptl_db/td_thr_getfpregs.c                    |   9 +-
 nptl_db/td_thr_getgregs.c                     |   9 +-
 nptl_db/td_thr_setfpregs.c                    |   9 +-
 nptl_db/td_thr_setgregs.c                     |   9 +-
 support/Makefile                              |   3 +-
 support/support.h                             |   4 +
 support/support_wait_for_thread_exit.c        |  72 ++++++++
 sysdeps/hppa/nptl/tcb-offsets.sym             |   1 -
 sysdeps/i386/nptl/tcb-offsets.sym             |   1 -
 sysdeps/nptl/dl-tls_init_tp.c                 |   4 +-
 sysdeps/nptl/libc_start_call_main.h           |   7 +
 sysdeps/nptl/pthreadP.h                       |  27 +--
 sysdeps/pthread/Makefile                      |   7 +-
 sysdeps/pthread/tst-kill4.c                   |  90 ----------
 sysdeps/pthread/tst-pthread_cancel-exited.c   |  45 +++++
 .../pthread/tst-pthread_cancel-select-loop.c  |  87 ++++++++++
 sysdeps/pthread/tst-pthread_kill-exited.c     |  46 +++++
 sysdeps/pthread/tst-pthread_kill-exiting.c    | 110 ++++++++++++
 sysdeps/pthread/tst-thrd-detach.c             |  16 +-
 sysdeps/sh/nptl/tcb-offsets.sym               |   1 -
 sysdeps/x86_64/nptl/tcb-offsets.sym           |   4 -
 54 files changed, 1037 insertions(+), 580 deletions(-)
 create mode 100644 nptl/tst-cleanup5.c
 create mode 100644 support/support_wait_for_thread_exit.c
 delete mode 100644 sysdeps/pthread/tst-kill4.c
 create mode 100644 sysdeps/pthread/tst-pthread_cancel-exited.c
 create mode 100644 sysdeps/pthread/tst-pthread_cancel-select-loop.c
 create mode 100644 sysdeps/pthread/tst-pthread_kill-exited.c
 create mode 100644 sysdeps/pthread/tst-pthread_kill-exiting.c

-- 
2.30.2


             reply	other threads:[~2021-08-23 19:52 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 19:50 Adhemerval Zanella via Libc-alpha [this message]
2021-08-23 19:50 ` [PATCH v2 01/19] nptl: Fix tst-cancel7 and tst-cancelx7 race condition (BZ #14232) Adhemerval Zanella via Libc-alpha
2021-08-26  9:33   ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 02/19] nptl: Set cancellation type and state on pthread_exit Adhemerval Zanella via Libc-alpha
2021-08-26  9:38   ` Florian Weimer via Libc-alpha
2021-08-26  9:42     ` Florian Weimer via Libc-alpha
2021-08-26 11:56       ` Adhemerval Zanella via Libc-alpha
2021-08-26 11:52     ` Adhemerval Zanella via Libc-alpha
2021-08-26 12:08       ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 03/19] nptl: Handle robust PI mutexes for !__ASSUME_SET_ROBUST_LIST Adhemerval Zanella via Libc-alpha
2021-08-26  9:42   ` Florian Weimer via Libc-alpha
2021-08-26 12:14     ` Adhemerval Zanella via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 04/19] nptl: Do not use pthread set_tid_address as state synchronization (BZ #19951) Adhemerval Zanella via Libc-alpha
2021-08-26 10:41   ` Florian Weimer via Libc-alpha
2021-08-26 14:58     ` Adhemerval Zanella via Libc-alpha
2021-08-26 15:06       ` Florian Weimer via Libc-alpha
2021-08-26 16:16         ` Adhemerval Zanella via Libc-alpha
2021-08-30 10:42           ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 05/19] nptl: Move setxid flag out of cancelhandling Adhemerval Zanella via Libc-alpha
2021-08-26 11:34   ` Florian Weimer via Libc-alpha
2021-08-26 15:11     ` Adhemerval Zanella via Libc-alpha
2021-08-26 15:21       ` Florian Weimer via Libc-alpha
2021-08-26 16:39         ` Adhemerval Zanella via Libc-alpha
2021-08-30 11:27           ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 06/19] nptl: Replace struct thread cancelhandling field Adhemerval Zanella via Libc-alpha
2021-08-26 14:34   ` Florian Weimer via Libc-alpha
2021-08-26 16:48     ` Adhemerval Zanella via Libc-alpha
2021-08-30 10:36       ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 07/19] support: Add support_wait_for_thread_exit Adhemerval Zanella via Libc-alpha
2021-08-26  9:31   ` Florian Weimer via Libc-alpha
2021-08-26 16:49     ` Adhemerval Zanella via Libc-alpha
2021-08-30 11:46       ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 08/19] nptl: pthread_kill, pthread_cancel should fail after exit (bug 19193) Adhemerval Zanella via Libc-alpha
2021-08-26 10:03   ` Florian Weimer via Libc-alpha
2021-08-26 16:49     ` Adhemerval Zanella via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 09/19] nptl: Fix race between pthread_kill and thread exit (bug 12889) Adhemerval Zanella via Libc-alpha
2021-08-26 14:23   ` Florian Weimer via Libc-alpha
2021-08-26 17:06     ` Adhemerval Zanella via Libc-alpha
2021-08-30  9:25       ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 10/19] nptl: Use tidlock when accessing TID on pthread_getaffinity_np Adhemerval Zanella via Libc-alpha
2021-08-26 14:24   ` Florian Weimer via Libc-alpha
2021-08-26 17:29     ` Adhemerval Zanella via Libc-alpha
2021-08-30  9:30       ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 11/19] nptl: Use tidlock when accessing TID on pthread_setaffinity Adhemerval Zanella via Libc-alpha
2021-08-26 14:25   ` Florian Weimer via Libc-alpha
2021-08-26 17:31     ` Adhemerval Zanella via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 12/19] nptl: Use tidlock when accessing TID on pthread_getcpuclockid Adhemerval Zanella via Libc-alpha
2021-08-26 14:27   ` Florian Weimer via Libc-alpha
2021-08-26 17:41     ` Adhemerval Zanella via Libc-alpha
2021-08-30  9:34       ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 13/19] nptl: Use tidlock when accessing TID on pthread_getschedparam Adhemerval Zanella via Libc-alpha
2021-08-26 15:00   ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 14/19] nptl: Use tidlock when accessing TID on pthread_setschedparam Adhemerval Zanella via Libc-alpha
2021-08-26 14:35   ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 15/19] nptl: Use tidlock when accessing TID on pthread_getname_np Adhemerval Zanella via Libc-alpha
2021-08-26 14:38   ` Florian Weimer via Libc-alpha
2021-08-26 17:45     ` Adhemerval Zanella via Libc-alpha
2021-08-30  9:37       ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 16/19] nptl: Use tidlock when accessing TID on pthread_setname_np Adhemerval Zanella via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 17/19] nptl: Use tidlock when accessing TID on pthread_sigqueue Adhemerval Zanella via Libc-alpha
2021-08-26 14:43   ` Florian Weimer via Libc-alpha
2021-08-26 17:49     ` Adhemerval Zanella via Libc-alpha
2021-08-30  9:26       ` Florian Weimer via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 18/19] nptl: Use tidlock when accessing TID on pthread_setschedprio Adhemerval Zanella via Libc-alpha
2021-08-23 19:50 ` [PATCH v2 19/19] nptl: Remove INVALID_TD_P Adhemerval Zanella via Libc-alpha
2021-08-26  9:30   ` Florian Weimer via Libc-alpha
2021-08-26 14:47 ` [PATCH v2 00/19] Fix various NPTL synchronization issues Florian Weimer via Libc-alpha
2021-08-26 18:19   ` Adhemerval Zanella 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=20210823195047.543237-1-adhemerval.zanella@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.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).