diff options
author | Cheryl Sabella <cheryl.sabella@gmail.com> | 2019-03-04 00:01:39 (GMT) |
---|---|---|
committer | larryhastings <larry@hastings.org> | 2019-03-04 00:01:39 (GMT) |
commit | 2226139aa2b69047cb54dbcfd79f5c2e36f98653 (patch) | |
tree | 2f223711a6cd167cc426007352bb702460304067 | |
parent | 765d333512e9b58da4a4431595a0e81517ef0443 (diff) | |
download | cpython-2226139aa2b69047cb54dbcfd79f5c2e36f98653.zip cpython-2226139aa2b69047cb54dbcfd79f5c2e36f98653.tar.gz cpython-2226139aa2b69047cb54dbcfd79f5c2e36f98653.tar.bz2 |
[3.4] bpo-33329: Fix multiprocessing regression on newer glibcs (GH-6575) (#12145)
Starting with glibc 2.27.9000-xxx, sigaddset() can return EINVAL for some
reserved signal numbers between 1 and NSIG. The `range(1, NSIG)` idiom
is commonly used to select all signals for blocking with `pthread_sigmask`.
So we ignore the sigaddset() return value until we expose sigfillset()
to provide a better idiom.
(cherry picked from commit 25038ec)
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
-rw-r--r-- | Misc/NEWS.d/next/Library/2018-04-23-13-21-39.bpo-33329.lQ-Eod.rst | 1 | ||||
-rw-r--r-- | Modules/signalmodule.c | 14 |
2 files changed, 9 insertions, 6 deletions
diff --git a/Misc/NEWS.d/next/Library/2018-04-23-13-21-39.bpo-33329.lQ-Eod.rst b/Misc/NEWS.d/next/Library/2018-04-23-13-21-39.bpo-33329.lQ-Eod.rst new file mode 100644 index 0000000..d1a4e56 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-04-23-13-21-39.bpo-33329.lQ-Eod.rst @@ -0,0 +1 @@ +Fix multiprocessing regression on newer glibcs diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index fedaddf..331a200 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -537,7 +537,6 @@ iterable_to_sigset(PyObject *iterable, sigset_t *mask) int result = -1; PyObject *iterator, *item; long signum; - int err; sigemptyset(mask); @@ -559,11 +558,14 @@ iterable_to_sigset(PyObject *iterable, sigset_t *mask) Py_DECREF(item); if (signum == -1 && PyErr_Occurred()) goto error; - if (0 < signum && signum < NSIG) - err = sigaddset(mask, (int)signum); - else - err = 1; - if (err) { + if (0 < signum && signum < NSIG) { + /* bpo-33329: ignore sigaddset() return value as it can fail + * for some reserved signals, but we want the `range(1, NSIG)` + * idiom to allow selecting all valid signals. + */ + (void) sigaddset(mask, (int)signum); + } + else { PyErr_Format(PyExc_ValueError, "signal number %ld out of range", signum); goto error; |