]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96652: Fix faulthandler chained signal without sigaction() (GH-96666)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 8 Sep 2022 10:43:24 +0000 (03:43 -0700)
committerGitHub <noreply@github.com>
Thu, 8 Sep 2022 10:43:24 +0000 (03:43 -0700)
Fix the faulthandler implementation of faulthandler.register(signal,
chain=True) if the sigaction() function is not available: don't call
the previous signal handler if it's NULL.
(cherry picked from commit c580a81af91af4b9df85e466f8b48c3c9c86c3df)

Co-authored-by: Victor Stinner <vstinner@python.org>
Misc/NEWS.d/next/Library/2022-09-07-22-49-37.gh-issue-96652.YqOKxI.rst [new file with mode: 0644]
Modules/faulthandler.c

diff --git a/Misc/NEWS.d/next/Library/2022-09-07-22-49-37.gh-issue-96652.YqOKxI.rst b/Misc/NEWS.d/next/Library/2022-09-07-22-49-37.gh-issue-96652.YqOKxI.rst
new file mode 100644 (file)
index 0000000..1d04db7
--- /dev/null
@@ -0,0 +1,3 @@
+Fix the faulthandler implementation of ``faulthandler.register(signal,
+chain=True)`` if the ``sigaction()`` function is not available: don't call
+the previous signal handler if it's NULL. Patch by Victor Stinner.
index 4af8702068b14b8a7e537ec4d497b5c3698b66b6..3ae62692e9677abab10ca784464a761fb5e5c0f9 100644 (file)
@@ -877,7 +877,7 @@ faulthandler_user(int signum)
         errno = save_errno;
     }
 #else
-    if (user->chain) {
+    if (user->chain && user->previous != NULL) {
         errno = save_errno;
         /* call the previous signal handler */
         user->previous(signum);