summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-11-07 06:05:20 (GMT)
committerGitHub <noreply@github.com>2022-11-07 06:05:20 (GMT)
commit1b5a62b88afd97475db7c4de72e65c08dd65d887 (patch)
treeff4cdca8e6c785df90bf62b3cdba75057df76fc6 /Modules
parent0d5b25bd8745ce26f80c50ae96dea2f44c9cf4fb (diff)
downloadcpython-1b5a62b88afd97475db7c4de72e65c08dd65d887.zip
cpython-1b5a62b88afd97475db7c4de72e65c08dd65d887.tar.gz
cpython-1b5a62b88afd97475db7c4de72e65c08dd65d887.tar.bz2
gh-96055: Update faulthandler to emit proper unexpect signal number (gh-99162)
(cherry picked from commit f626b7b504df454d289527a4f922b09deeae9e21) Co-authored-by: Dong-hee Na <donghee.na@python.org>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/faulthandler.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 3ae6269..8d2221c 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -349,14 +349,17 @@ faulthandler_fatal_error(int signum)
size_t i;
fault_handler_t *handler = NULL;
int save_errno = errno;
+ int found = 0;
if (!fatal_error.enabled)
return;
for (i=0; i < faulthandler_nsignals; i++) {
handler = &faulthandler_handlers[i];
- if (handler->signum == signum)
+ if (handler->signum == signum) {
+ found = 1;
break;
+ }
}
if (handler == NULL) {
/* faulthandler_nsignals == 0 (unlikely) */
@@ -366,9 +369,18 @@ faulthandler_fatal_error(int signum)
/* restore the previous handler */
faulthandler_disable_fatal_handler(handler);
- PUTS(fd, "Fatal Python error: ");
- PUTS(fd, handler->name);
- PUTS(fd, "\n\n");
+ if (found) {
+ PUTS(fd, "Fatal Python error: ");
+ PUTS(fd, handler->name);
+ PUTS(fd, "\n\n");
+ }
+ else {
+ char unknown_signum[23] = {0,};
+ snprintf(unknown_signum, 23, "%d", signum);
+ PUTS(fd, "Fatal Python error from unexpected signum: ");
+ PUTS(fd, unknown_signum);
+ PUTS(fd, "\n\n");
+ }
faulthandler_dump_traceback(fd, fatal_error.all_threads,
fatal_error.interp);