Go to file
Jeremie Koenig 653d74f12a hurd: Global signal disposition
This adds _hurd_sigstate_set_global_rcv used by libpthread to enable
POSIX-confirming behavior of signals on a per-thread basis.

This also provides a sigstate destructor _hurd_sigstate_delete, and a
global process signal state, which needs to be locked and check when
global disposition is enabled, thus the addition of _hurd_sigstate_lock
_hurd_sigstate_actions _hurd_sigstate_pending _hurd_sigstate_unlock helpers.

This also updates all the glibc code accordingly.

This also drops support for get_int(INIT_SIGMASK), which did not make sense
any more since we do not have a single signal thread any more.

During fork/spawn, this also reinitializes the child global sigstate's
lock. That cures an issue that would very rarely cause a deadlock in the
child in fork, tries to unlock ss' critical section lock at the end of
fork.  This will typically (always?) be observed in /bin/sh, which is not
surprising as that is the foremost caller of fork.

To reproduce an intermediate state, add an endless loop if
_hurd_global_sigstate is locked after __proc_dostop (cast through
volatile); that is, while still being in the fork's parent process.

When that triggers (use the libtool testsuite), the signal thread has
already locked ss (which is _hurd_global_sigstate), and is stuck at
hurdsig.c:685 in post_signal, trying to lock _hurd_siglock (which the
main thread already has locked and keeps locked until after
__task_create).  This is the case that ss->thread == MACH_PORT_NULL, that
is, a global signal.  In the main thread, between __proc_dostop and
__task_create is the __thread_abort call on the signal thread which would
abort any current kernel operation (but leave ss locked).  Later in fork,
in the parent, when _hurd_siglock is unlocked in fork, the parent's
signal thread can proceed and will unlock eventually the global sigstate.
In the client, _hurd_siglock will likewise be unlocked, but the global
sigstate never will be, as the client's signal thread has been configured
to restart execution from _hurd_msgport_receive.  Thus, when the child
tries to unlock ss' critical section lock at the end of fork, it will
first lock the global sigstate, will spin trying to lock it, which can
never be successful, and we get our deadlock.

Options seem to be:

  * Move the locking of _hurd_siglock earlier in post_signal -- but that
    may generally impact performance, if this locking isn't generally
    needed anyway?

    On the other hand, would it actually make sense to wait here until we
    are not any longer in a critical section (which is meant to disable
    signal delivery anyway (but not for preempted signals?))?

  * Clear the global sigstate in the fork's child with the rationale that
    we're anyway restarting the signal thread from a clean state.  This
    has now been implemented.

Why has this problem not been observed before Jérémie's patches?  (Or has
it?  Perhaps even more rarely?)  In _S_msg_sig_post, the signal is now
posted to a *global receiver thread*, whereas previously it was posted to
the *designated signal-receiving thread*.  The latter one was in a
critical section in fork, so didn't try to handle the signal until after
leaving the critical section?  (Not completely analyzed and verified.)

Another question is what the signal is that is being received
during/around the time __proc_dostop executes.
2019-12-29 18:32:49 +01:00
argp
assert Fix failure when CFLAGS contains -DNDEBUG (Bug 25251) 2019-12-10 12:22:42 -05:00
benchtests
bits Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 2019-12-27 15:02:10 -03:00
catgets
ChangeLog.old
conform
crypt
csu
ctype
debug
dirent
dlfcn
elf Fix test isolation for elf/tst-ifunc-fault-lazy, elf/tst-ifunc-fault-bindnow 2019-12-19 16:06:50 +01:00
gmon
gnulib
grp
gshadow
hesiod
htl
hurd hurd: Global signal disposition 2019-12-29 18:32:49 +01:00
iconv
iconvdata
include Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 2019-12-27 15:02:10 -03:00
inet
intl
io hurd: Fix ld.so __access override from libc 2019-12-01 21:05:56 +00:00
libio Remove __waitpid_nocancel 2019-12-19 16:11:09 -03:00
locale
localedata mnw_MM, my_MM, and shn_MM locales: Do not use %Op 2019-12-23 23:49:22 +01:00
login
mach hurd: make strerror(0) coherent with other ports 2019-12-01 16:36:43 +00:00
malloc Correct range checking in mallopt/mxfast/tcache [BZ #25194] 2019-12-05 16:46:37 -05:00
manual aarch64: Add Huawei Kunpeng to tunable cpu list 2019-12-19 16:31:04 -03:00
math
mathvec
misc ldbl-128ibm-compat: Add *cvt functions 2019-12-23 16:32:20 -03:00
nis
nptl nptl: Move waitpid implementation to libc 2019-12-19 16:11:09 -03:00
nptl_db
nscd
nss
po
posix Add exception-based flags for wait4 2019-12-20 09:59:11 -03:00
pwd
resolv resolv: Implement trust-ad option for /etc/resolv.conf [BZ #20358] 2019-11-27 20:54:37 +01:00
resource
rt
scripts build-many-glibcs.py: Do not build C++ PCHs by default 2019-12-18 08:47:45 +01:00
setjmp
shadow
signal
socket
soft-fp
stdio-common
stdlib hurd: Fix local PLT 2019-12-13 11:11:54 +01:00
string <string.h>: Define __CORRECT_ISO_CPP_STRING_H_PROTO for Clang [BZ #25232] 2019-12-05 16:50:00 +01:00
sunrpc
support resolv: Implement trust-ad option for /etc/resolv.conf [BZ #20358] 2019-11-27 20:54:37 +01:00
sysdeps hurd: Global signal disposition 2019-12-29 18:32:49 +01:00
sysvipc
termios
time
timezone
wcsmbs
wctype
.gitattributes
.gitignore
abi-tags
aclocal.m4
config.h.in
config.make.in
configure x86: Assume --enable-cet if GCC defaults to CET [BZ #25225] 2019-12-03 18:48:18 +01:00
configure.ac x86: Assume --enable-cet if GCC defaults to CET [BZ #25225] 2019-12-03 18:48:18 +01:00
COPYING
COPYING.LIB
extra-lib.mk
gen-locales.mk
INSTALL
libc-abis
libof-iterator.mk
LICENSES
MAINTAINERS
Makeconfig Expand $(as-needed) and $(no-as-needed) throughout the build system 2019-12-03 21:37:50 +01:00
Makefile Do not use ld.so to open statically linked programs in debugglibc.sh 2019-12-04 09:17:06 -03:00
Makefile.help
Makefile.in
Makerules Expand $(as-needed) and $(no-as-needed) throughout the build system 2019-12-03 21:37:50 +01:00
NEWS Lazy binding failures during dlopen/dlclose must be fatal [BZ #24304] 2019-11-27 20:55:35 +01:00
o-iterator.mk
README
Rules
shlib-versions
test-skeleton.c
version.h

This directory contains the sources of the GNU C Library.
See the file "version.h" for what release version you have.

The GNU C Library is the standard system C library for all GNU systems,
and is an important part of what makes up a GNU system.  It provides the
system API for all programs written in C and C-compatible languages such
as C++ and Objective C; the runtime facilities of other programming
languages use the C library to access the underlying operating system.

In GNU/Linux systems, the C library works with the Linux kernel to
implement the operating system behavior seen by user applications.
In GNU/Hurd systems, it works with a microkernel and Hurd servers.

The GNU C Library implements much of the POSIX.1 functionality in the
GNU/Hurd system, using configurations i[4567]86-*-gnu.

When working with Linux kernels, this version of the GNU C Library
requires Linux kernel version 3.2 or later.

Also note that the shared version of the libgcc_s library must be
installed for the pthread library to work correctly.

The GNU C Library supports these configurations for using Linux kernels:

	aarch64*-*-linux-gnu
	alpha*-*-linux-gnu
	arm-*-linux-gnueabi
	csky-*-linux-gnuabiv2
	hppa-*-linux-gnu
	i[4567]86-*-linux-gnu
	x86_64-*-linux-gnu	Can build either x86_64 or x32
	ia64-*-linux-gnu
	m68k-*-linux-gnu
	microblaze*-*-linux-gnu
	mips-*-linux-gnu
	mips64-*-linux-gnu
	powerpc-*-linux-gnu	Hardware or software floating point, BE only.
	powerpc64*-*-linux-gnu	Big-endian and little-endian.
	s390-*-linux-gnu
	s390x-*-linux-gnu
	riscv64-*-linux-gnu
	sh[34]-*-linux-gnu
	sparc*-*-linux-gnu
	sparc64*-*-linux-gnu

If you are interested in doing a port, please contact the glibc
maintainers; see https://www.gnu.org/software/libc/ for more
information.

See the file INSTALL to find out how to configure, build, and install
the GNU C Library.  You might also consider reading the WWW pages for
the C library at https://www.gnu.org/software/libc/.

The GNU C Library is (almost) completely documented by the Texinfo manual
found in the `manual/' subdirectory.  The manual is still being updated
and contains some known errors and omissions; we regret that we do not
have the resources to work on the manual as much as we would like.  For
corrections to the manual, please file a bug in the `manual' component,
following the bug-reporting instructions below.  Please be sure to check
the manual in the current development sources to see if your problem has
already been corrected.

Please see https://www.gnu.org/software/libc/bugs.html for bug reporting
information.  We are now using the Bugzilla system to track all bug reports.
This web page gives detailed information on how to report bugs properly.

The GNU C Library is free software.  See the file COPYING.LIB for copying
conditions, and LICENSES for notices about a few contributions that require
these additional notices to be distributed.  License copyright years may be
listed using range notation, e.g., 1996-2015, indicating that every year in
the range, inclusive, is a copyrightable year that would otherwise be listed
individually.