[Python-checkins] gh-96652: Fix faulthandler chained signal without sigaction() (GH-96666)

miss-islington webhook-mailer at python.org
Thu Sep 8 06:47:13 EDT 2022


https://github.com/python/cpython/commit/3d6e6beb0d85f064a19e60012d140b5bc4ea0cca
commit: 3d6e6beb0d85f064a19e60012d140b5bc4ea0cca
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-09-08T03:47:07-07:00
summary:

gh-96652: Fix faulthandler chained signal without sigaction() (GH-96666)


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 at python.org>

files:
A Misc/NEWS.d/next/Library/2022-09-07-22-49-37.gh-issue-96652.YqOKxI.rst
M 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
index 000000000000..1d04db7b2a25
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-09-07-22-49-37.gh-issue-96652.YqOKxI.rst
@@ -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.
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 3026bb6a3432..4847c1cb87bc 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -862,7 +862,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);



More information about the Python-checkins mailing list