summaryrefslogtreecommitdiffstats
path: root/Modules/faulthandler.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-04-25 22:13:31 (GMT)
committerGitHub <noreply@github.com>2022-04-25 22:13:31 (GMT)
commit20cc69528677b3e5191139d1cb587531f4893b55 (patch)
tree50c706da1e4040b15b1d2cda8eb7a1a13a48b7dc /Modules/faulthandler.c
parent61381d7da1233849b280706f11dbcae4deed949d (diff)
downloadcpython-20cc69528677b3e5191139d1cb587531f4893b55.zip
cpython-20cc69528677b3e5191139d1cb587531f4893b55.tar.gz
cpython-20cc69528677b3e5191139d1cb587531f4893b55.tar.bz2
gh-64783: Fix signal.NSIG value on FreeBSD (#91929)
Fix signal.NSIG value on FreeBSD to accept signal numbers greater than 32, like signal.SIGRTMIN and signal.SIGRTMAX. * Add Py_NSIG constant. * Add pycore_signal.h internal header file. * _Py_Sigset_Converter() now includes the range of valid signals in the error message.
Diffstat (limited to 'Modules/faulthandler.c')
-rw-r--r--Modules/faulthandler.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 91f9666..4f709ed 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -2,6 +2,7 @@
#include "pycore_initconfig.h" // _PyStatus_ERR
#include "pycore_pyerrors.h" // _Py_DumpExtensionModules
#include "pycore_pystate.h" // _PyThreadState_GET()
+#include "pycore_signal.h" // Py_NSIG
#include "pycore_traceback.h" // _Py_DumpTracebackThreads
#include "frameobject.h"
@@ -115,19 +116,6 @@ typedef struct {
static user_signal_t *user_signals;
-/* the following macros come from Python: Modules/signalmodule.c */
-#ifndef NSIG
-# if defined(_NSIG)
-# define NSIG _NSIG /* For BSD/SysV */
-# elif defined(_SIGMAX)
-# define NSIG (_SIGMAX + 1) /* For QNX */
-# elif defined(SIGMAX)
-# define NSIG (SIGMAX + 1) /* For djgpp */
-# else
-# define NSIG 64 /* Use a reasonable default value */
-# endif
-#endif
-
static void faulthandler_user(int signum);
#endif /* FAULTHANDLER_USER */
@@ -896,7 +884,7 @@ check_signum(int signum)
return 0;
}
}
- if (signum < 1 || NSIG <= signum) {
+ if (signum < 1 || Py_NSIG <= signum) {
PyErr_SetString(PyExc_ValueError, "signal number out of range");
return 0;
}
@@ -935,7 +923,7 @@ faulthandler_register_py(PyObject *self,
return NULL;
if (user_signals == NULL) {
- user_signals = PyMem_Calloc(NSIG, sizeof(user_signal_t));
+ user_signals = PyMem_Calloc(Py_NSIG, sizeof(user_signal_t));
if (user_signals == NULL)
return PyErr_NoMemory();
}
@@ -1215,7 +1203,7 @@ faulthandler_traverse(PyObject *module, visitproc visit, void *arg)
Py_VISIT(thread.file);
#ifdef FAULTHANDLER_USER
if (user_signals != NULL) {
- for (size_t signum=0; signum < NSIG; signum++)
+ for (size_t signum=0; signum < Py_NSIG; signum++)
Py_VISIT(user_signals[signum].file);
}
#endif
@@ -1416,7 +1404,7 @@ void _PyFaulthandler_Fini(void)
#ifdef FAULTHANDLER_USER
/* user */
if (user_signals != NULL) {
- for (size_t signum=0; signum < NSIG; signum++) {
+ for (size_t signum=0; signum < Py_NSIG; signum++) {
faulthandler_unregister(&user_signals[signum], signum);
}
PyMem_Free(user_signals);