Visitar URL original
gh-81057: Move faulthandler Globals to _PyRuntimeState by ericsnowcurrently · Pull Request #100152 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move fatal_error to _PyRuntimeState.
  • Loading branch information
ericsnowcurrently committed Dec 12, 2022
commit 16ef584a0dff956fc9a6a4d2bf0159a9070dc305
17 changes: 17 additions & 0 deletions Include/internal/pycore_faulthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,25 @@ extern "C" {

struct _faulthandler_runtime_state {
int _not_used;
struct {
int enabled;
PyObject *file;
int fd;
int all_threads;
PyInterpreterState *interp;
#ifdef MS_WINDOWS
void *exc_handler;
#endif
} fatal_error;
};

#define _faulthandler_runtime_state_INIT \
{ \
.fatal_error = { \
.fd = -1, \
}, \
}


#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_runtime_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extern "C" {
.fileutils = { \
.force_ascii = -1, \
}, \
.faulthandler = _faulthandler_runtime_state_INIT, \
.tracemalloc = _tracemalloc_runtime_state_INIT, \
.float_state = { \
.float_format = _py_float_format_unknown, \
Expand Down
11 changes: 1 addition & 10 deletions Modules/faulthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,7 @@ typedef struct {
int all_threads;
} fault_handler_t;

static struct {
int enabled;
PyObject *file;
int fd;
int all_threads;
PyInterpreterState *interp;
#ifdef MS_WINDOWS
void *exc_handler;
#endif
} fatal_error = {0, NULL, -1, 0};
#define fatal_error _PyRuntime.faulthandler.fatal_error

static struct {
PyObject *file;
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ Modules/itertoolsmodule.c - ziplongest_type -
##-----------------------
## state

Modules/faulthandler.c - fatal_error -
Modules/faulthandler.c - thread -
Modules/faulthandler.c - user_signals -
Modules/faulthandler.c - stack -
Expand Down