Skip to content

Commit 15fcae5

Browse files
Move stack and old_stack to _PyRuntimeState.
1 parent 820ebf1 commit 15fcae5

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

Include/internal/pycore_faulthandler.h

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
1211
#ifdef HAVE_SIGACTION
13-
#include <signal.h>
12+
# include <signal.h>
1413
#endif
1514

1615

@@ -23,10 +22,15 @@ extern "C" {
2322

2423

2524
#ifdef HAVE_SIGACTION
25+
/* Using an alternative stack requires sigaltstack()
26+
and sigaction() SA_ONSTACK */
27+
# ifdef HAVE_SIGALTSTACK
28+
# define FAULTHANDLER_USE_ALT_STACK
29+
# endif
2630
typedef struct sigaction _Py_sighandler_t;
2731
#else
2832
typedef PyOS_sighandler_t _Py_sighandler_t;
29-
#endif
33+
#endif // HAVE_SIGACTION
3034

3135

3236
#ifdef FAULTHANDLER_USER
@@ -74,6 +78,11 @@ struct _faulthandler_runtime_state {
7478
#ifdef FAULTHANDLER_USER
7579
struct faulthandler_user_signal *user_signals;
7680
#endif
81+
82+
#ifdef FAULTHANDLER_USE_ALT_STACK
83+
stack_t stack;
84+
stack_t old_stack;
85+
#endif
7786
};
7887

7988
#define _faulthandler_runtime_state_INIT \

Modules/faulthandler.c

+2-8
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
# include <sys/resource.h>
1919
#endif
2020

21-
/* Using an alternative stack requires sigaltstack()
22-
and sigaction() SA_ONSTACK */
23-
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
24-
# define FAULTHANDLER_USE_ALT_STACK
25-
#endif
26-
2721
#if defined(FAULTHANDLER_USE_ALT_STACK) && defined(HAVE_LINUX_AUXVEC_H) && defined(HAVE_SYS_AUXV_H)
2822
# include <linux/auxvec.h> // AT_MINSIGSTKSZ
2923
# include <sys/auxv.h> // getauxval()
@@ -86,8 +80,8 @@ static const size_t faulthandler_nsignals = \
8680
Py_ARRAY_LENGTH(faulthandler_handlers);
8781

8882
#ifdef FAULTHANDLER_USE_ALT_STACK
89-
static stack_t stack;
90-
static stack_t old_stack;
83+
# define stack _PyRuntime.faulthandler.stack
84+
# define old_stack _PyRuntime.faulthandler.old_stack
9185
#endif
9286

9387

Tools/c-analyzer/cpython/globals-to-fix.tsv

-6
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,6 @@ Modules/itertoolsmodule.c - tee_type -
361361
Modules/itertoolsmodule.c - teedataobject_type -
362362
Modules/itertoolsmodule.c - ziplongest_type -
363363

364-
##-----------------------
365-
## state
366-
367-
Modules/faulthandler.c - stack -
368-
Modules/faulthandler.c - old_stack -
369-
370364

371365
##################################
372366
## global non-objects to fix in builtin modules

0 commit comments

Comments
 (0)