1919/* Allocate at maximum 100 MiB of the stack to raise the stack overflow */
2020#define STACK_OVERFLOW_MAX_SIZE (100 * 1024 * 1024)
2121
22- #define FAULTHANDLER_LATER
23-
2422#ifndef MS_WINDOWS
2523 /* register() is useless on Windows, because only SIGSEGV, SIGABRT and
2624 SIGILL can be handled by the process, and these signals can only be used
@@ -60,7 +58,6 @@ static struct {
6058#endif
6159} fatal_error = {0 , NULL , -1 , 0 };
6260
63- #ifdef FAULTHANDLER_LATER
6461static struct {
6562 PyObject * file ;
6663 int fd ;
@@ -77,7 +74,6 @@ static struct {
7774 /* released by child thread when joined */
7875 PyThread_type_lock running ;
7976} thread ;
80- #endif
8177
8278#ifdef FAULTHANDLER_USER
8379typedef struct {
@@ -589,8 +585,6 @@ faulthandler_is_enabled(PyObject *self, PyObject *Py_UNUSED(ignored))
589585 return PyBool_FromLong (fatal_error .enabled );
590586}
591587
592- #ifdef FAULTHANDLER_LATER
593-
594588static void
595589faulthandler_thread (void * unused )
596590{
@@ -790,7 +784,6 @@ faulthandler_cancel_dump_traceback_later_py(PyObject *self,
790784 cancel_dump_traceback_later ();
791785 Py_RETURN_NONE ;
792786}
793- #endif /* FAULTHANDLER_LATER */
794787
795788
796789#ifdef FAULTHANDLER_USER
@@ -1230,9 +1223,7 @@ faulthandler_stack_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
12301223static int
12311224faulthandler_traverse (PyObject * module , visitproc visit , void * arg )
12321225{
1233- #ifdef FAULTHANDLER_LATER
12341226 Py_VISIT (thread .file );
1235- #endif
12361227#ifdef FAULTHANDLER_USER
12371228 if (user_signals != NULL ) {
12381229 for (size_t signum = 0 ; signum < NSIG ; signum ++ )
@@ -1273,7 +1264,6 @@ static PyMethodDef module_methods[] = {
12731264 PyDoc_STR ("dump_traceback(file=sys.stderr, all_threads=True): "
12741265 "dump the traceback of the current thread, or of all threads "
12751266 "if all_threads is True, into file" )},
1276- #ifdef FAULTHANDLER_LATER
12771267 {"dump_traceback_later" ,
12781268 (PyCFunction )(void (* )(void ))faulthandler_dump_traceback_later , METH_VARARGS |METH_KEYWORDS ,
12791269 PyDoc_STR ("dump_traceback_later(timeout, repeat=False, file=sys.stderrn, exit=False):\n"
@@ -1284,8 +1274,6 @@ static PyMethodDef module_methods[] = {
12841274 faulthandler_cancel_dump_traceback_later_py , METH_NOARGS ,
12851275 PyDoc_STR ("cancel_dump_traceback_later():\ncancel the previous call "
12861276 "to dump_traceback_later()." )},
1287- #endif
1288-
12891277#ifdef FAULTHANDLER_USER
12901278 {"register" ,
12911279 (PyCFunction )(void (* )(void ))faulthandler_register_py , METH_VARARGS |METH_KEYWORDS ,
@@ -1298,7 +1286,6 @@ static PyMethodDef module_methods[] = {
12981286 PyDoc_STR ("unregister(signum): unregister the handler of the signal "
12991287 "'signum' registered by register()" )},
13001288#endif
1301-
13021289 {"_read_null" , faulthandler_read_null , METH_NOARGS ,
13031290 PyDoc_STR ("_read_null(): read from NULL, raise "
13041291 "a SIGSEGV or SIGBUS signal depending on the platform" )},
@@ -1399,9 +1386,7 @@ _PyFaulthandler_Init(int enable)
13991386 stack .ss_size = SIGSTKSZ * 2 ;
14001387#endif
14011388
1402- #ifdef FAULTHANDLER_LATER
14031389 memset (& thread , 0 , sizeof (thread ));
1404- #endif
14051390
14061391 if (enable ) {
14071392 if (faulthandler_init_enable () < 0 ) {
@@ -1413,7 +1398,6 @@ _PyFaulthandler_Init(int enable)
14131398
14141399void _PyFaulthandler_Fini (void )
14151400{
1416- #ifdef FAULTHANDLER_LATER
14171401 /* later */
14181402 if (thread .cancel_event ) {
14191403 cancel_dump_traceback_later ();
@@ -1425,7 +1409,6 @@ void _PyFaulthandler_Fini(void)
14251409 PyThread_free_lock (thread .running );
14261410 thread .running = NULL ;
14271411 }
1428- #endif
14291412
14301413#ifdef FAULTHANDLER_USER
14311414 /* user */
0 commit comments