Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 820ebf1

Browse files
committedDec 12, 2022
Move user_signals to _PyRuntimeState.
1 parent b280eee commit 820ebf1

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed
 

‎Include/internal/pycore_faulthandler.h

+37
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,39 @@ extern "C" {
99
#endif
1010

1111

12+
#ifdef HAVE_SIGACTION
13+
#include <signal.h>
14+
#endif
15+
16+
17+
#ifndef MS_WINDOWS
18+
/* register() is useless on Windows, because only SIGSEGV, SIGABRT and
19+
SIGILL can be handled by the process, and these signals can only be used
20+
with enable(), not using register() */
21+
# define FAULTHANDLER_USER
22+
#endif
23+
24+
25+
#ifdef HAVE_SIGACTION
26+
typedef struct sigaction _Py_sighandler_t;
27+
#else
28+
typedef PyOS_sighandler_t _Py_sighandler_t;
29+
#endif
30+
31+
32+
#ifdef FAULTHANDLER_USER
33+
struct faulthandler_user_signal {
34+
int enabled;
35+
PyObject *file;
36+
int fd;
37+
int all_threads;
38+
int chain;
39+
_Py_sighandler_t previous;
40+
PyInterpreterState *interp;
41+
};
42+
#endif /* FAULTHANDLER_USER */
43+
44+
1245
struct _faulthandler_runtime_state {
1346
struct {
1447
int enabled;
@@ -37,6 +70,10 @@ struct _faulthandler_runtime_state {
3770
/* released by child thread when joined */
3871
PyThread_type_lock running;
3972
} thread;
73+
74+
#ifdef FAULTHANDLER_USER
75+
struct faulthandler_user_signal *user_signals;
76+
#endif
4077
};
4178

4279
#define _faulthandler_runtime_state_INIT \

‎Modules/faulthandler.c

+2-25
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
/* Allocate at maximum 100 MiB of the stack to raise the stack overflow */
3333
#define STACK_OVERFLOW_MAX_SIZE (100 * 1024 * 1024)
3434

35-
#ifndef MS_WINDOWS
36-
/* register() is useless on Windows, because only SIGSEGV, SIGABRT and
37-
SIGILL can be handled by the process, and these signals can only be used
38-
with enable(), not using register() */
39-
# define FAULTHANDLER_USER
40-
#endif
41-
4235
#define PUTS(fd, str) _Py_write_noraise(fd, str, strlen(str))
4336

4437

@@ -58,12 +51,6 @@
5851
#endif
5952

6053

61-
#ifdef HAVE_SIGACTION
62-
typedef struct sigaction _Py_sighandler_t;
63-
#else
64-
typedef PyOS_sighandler_t _Py_sighandler_t;
65-
#endif
66-
6754
typedef struct {
6855
int signum;
6956
int enabled;
@@ -76,18 +63,8 @@ typedef struct {
7663
#define thread _PyRuntime.faulthandler.thread
7764

7865
#ifdef FAULTHANDLER_USER
79-
typedef struct {
80-
int enabled;
81-
PyObject *file;
82-
int fd;
83-
int all_threads;
84-
int chain;
85-
_Py_sighandler_t previous;
86-
PyInterpreterState *interp;
87-
} user_signal_t;
88-
89-
static user_signal_t *user_signals;
90-
66+
#define user_signals _PyRuntime.faulthandler.user_signals
67+
typedef struct faulthandler_user_signal user_signal_t;
9168
static void faulthandler_user(int signum);
9269
#endif /* FAULTHANDLER_USER */
9370

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

-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ Modules/itertoolsmodule.c - ziplongest_type -
364364
##-----------------------
365365
## state
366366

367-
Modules/faulthandler.c - user_signals -
368367
Modules/faulthandler.c - stack -
369368
Modules/faulthandler.c - old_stack -
370369

0 commit comments

Comments
 (0)
Please sign in to comment.