]> granicus.if.org Git - python/commitdiff
bpo-33329: Fix multiprocessing regression on newer glibcs (GH-6575)
authorAntoine Pitrou <pitrou@free.fr>
Mon, 23 Apr 2018 18:53:33 +0000 (20:53 +0200)
committerGitHub <noreply@github.com>
Mon, 23 Apr 2018 18:53:33 +0000 (20:53 +0200)
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.

Misc/NEWS.d/next/Library/2018-04-23-13-21-39.bpo-33329.lQ-Eod.rst [new file with mode: 0644]
Modules/signalmodule.c

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 (file)
index 0000000..d1a4e56
--- /dev/null
@@ -0,0 +1 @@
+Fix multiprocessing regression on newer glibcs
index 7916160143840c59eefcfb01a408a33baa125283..35fd87e2d1e711ffc6f4debab4a49950cfe4f9f0 100644 (file)
@@ -819,7 +819,6 @@ iterable_to_sigset(PyObject *iterable, sigset_t *mask)
     int result = -1;
     PyObject *iterator, *item;
     long signum;
-    int err;
 
     sigemptyset(mask);
 
@@ -841,11 +840,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;