glibc/sysdeps/nptl
Adhemerval Zanella 404656009b nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
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>
2022-04-14 12:48:31 -03:00
..
bits Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
sys Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
_Fork.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
aio_misc.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
dl-mutex.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
dl-thread_gscope_wait.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
dl-tls_init_tp.c nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029) 2022-04-14 12:48:31 -03:00
dl-tunables.list Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
fork.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
futex-internal.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
gai_misc.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
Implies
internaltypes.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
jmp-unwind.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
libc-lock.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
libc-lockP.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
libc_start_call_main.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
lowlevellock-futex.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
lowlevellock.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
Makeconfig Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
Makefile Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
malloc-machine.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
proc_service.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
pthread-offsets.h nptl: update default pthread-offsets.h 2020-02-10 17:01:21 +01:00
pthread.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
pthread_atfork_compat.h Consolidate pthread_atfork 2021-06-24 10:04:41 -03:00
pthread_early_init.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
pthread_mutex_conf.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
pthreadP.h nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029) 2022-04-14 12:48:31 -03:00
setxid.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
stdio-lock.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
Subdirs
tcb-access.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
tcb-offsets.h
thread_db.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
thread_pointer.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
timer_routines.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
tst-mqueue8x.c