[0/3] Fix ESRCH issues in pthread_cancel, pthread_kill

Message ID cover.1629208174.git.fweimer@redhat.com
Headers
Series Fix ESRCH issues in pthread_cancel, pthread_kill |

Message

Florian Weimer Aug. 17, 2021, 1:50 p.m. UTC
  This mini-series came out of a downstream bug report:

  glibc: pthread_cancel fails with ESRCH yet subsequent pthread_join passes
  <https://bugzilla.redhat.com/show_bug.cgi?id=1994068>

Apparently the race is much easier to trigger due to the changes in
glibc 2.34.

Tested on i686-linux-gnu, x86_64-linux-gnu.  Built with
build-many-glibcs.py.

Thanks,
Florian

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/allocatestack.c                          |   1 +
 nptl/descr.h                                  |  12 ++
 nptl/pthread_cancel.c                         |   9 +-
 nptl/pthread_create.c                         |  20 ++++
 nptl/pthread_kill.c                           |  30 ++++-
 support/Makefile                              |   3 +-
 support/support.h                             |   4 +
 support/support_wait_for_thread_exit.c        |  67 +++++++++++
 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 ++++++++++++++++++
 14 files changed, 431 insertions(+), 100 deletions(-)
 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