66#include "pycore_traceback.h" // _Py_DumpTracebackThreads
77
88#include <object.h>
9- #include <signal.h>
9+ #include <signal.h> // sys_signame
1010#include <stdlib.h> // abort()
1111#if defined(HAVE_PTHREAD_SIGMASK ) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK ) && defined(HAVE_PTHREAD_H )
1212# include <pthread.h>
@@ -333,14 +333,17 @@ faulthandler_fatal_error(int signum)
333333 size_t i ;
334334 fault_handler_t * handler = NULL ;
335335 int save_errno = errno ;
336+ int found = 0 ;
336337
337338 if (!fatal_error .enabled )
338339 return ;
339340
340341 for (i = 0 ; i < faulthandler_nsignals ; i ++ ) {
341342 handler = & faulthandler_handlers [i ];
342- if (handler -> signum == signum )
343+ if (handler -> signum == signum ) {
344+ found = 1 ;
343345 break ;
346+ }
344347 }
345348 if (handler == NULL ) {
346349 /* faulthandler_nsignals == 0 (unlikely) */
@@ -350,9 +353,16 @@ faulthandler_fatal_error(int signum)
350353 /* restore the previous handler */
351354 faulthandler_disable_fatal_handler (handler );
352355
353- PUTS (fd , "Fatal Python error: " );
354- PUTS (fd , handler -> name );
355- PUTS (fd , "\n\n" );
356+ if (found ) {
357+ PUTS (fd , "Fatal Python error: " );
358+ PUTS (fd , handler -> name );
359+ PUTS (fd , "\n\n" );
360+ }
361+ else {
362+ PUTS (fd , "Fatal Python error from unexpected signal: " );
363+ PUTS (fd , strdup (sys_signame [signum ]));
364+ PUTS (fd , "\n\n" );
365+ }
356366
357367 faulthandler_dump_traceback (fd , fatal_error .all_threads ,
358368 fatal_error .interp );
0 commit comments