8000 gh-81057: Move faulthandler Globals to _PyRuntimeState by ericsnowcurrently · Pull Request #100152 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-81057: Move faulthandler Globals to _PyRuntimeState #100152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 stack and old_stack to _PyRuntimeState.
  • Loading branch information
ericsnowcurrently committed Dec 12, 2022
commit 15fcae556c68362bbb438cbd774c10aa48fca2fb
15 changes: 12 additions & 3 deletions Include/internal/pycore_faulthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif


#ifdef HAVE_SIGACTION
#include <signal.h>
# include <signal.h>
#endif


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


#ifdef HAVE_SIGACTION
/* Using an alternative stack requires sigaltstack()
and sigaction() SA_ONSTACK */
# ifdef HAVE_SIGALTSTACK
# define FAULTHANDLER_USE_ALT_STACK
# endif
typedef struct sigaction _Py_sighandler_t;
#else
typedef PyOS_sighandler_t _Py_sighandler_t;
#endif
#endif // HAVE_SIGACTION


#ifdef FAULTHANDLER_USER
Expand Down Expand Up @@ -74,6 +78,11 @@ struct _faulthandler_runtime_state {
#ifdef FAULTHANDLER_USER
struct faulthandler_user_signal *user_signals;
#endif

#ifdef FAULTHANDLER_USE_ALT_STACK
stack_t stack;
stack_t old_stack;
#endif
};

#define _faulthandler_runtime_state_INIT \
Expand Down
10 changes: 2 additions & 8 deletions Modules/faulthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
# include <sys/resource.h>
#endif

/* Using an alternative stack requires sigaltstack()
and sigaction() SA_ONSTACK */
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
# define FAULTHANDLER_USE_ALT_STACK
#endif

#if defined(FAULTHANDLER_USE_ALT_STACK) && defined(HAVE_LINUX_AUXVEC_H) && defined(HAVE_SYS_AUXV_H)
# include <linux/auxvec.h> // AT_MINSIGSTKSZ
# include <sys/auxv.h> // getauxval()
Expand Down Expand Up @@ -86,8 +80,8 @@ static const size_t faulthandler_nsignals = \
Py_ARRAY_LENGTH(faulthandler_handlers);

#ifdef FAULTHANDLER_USE_ALT_STACK
static stack_t stack;
static stack_t old_stack;
# define stack _PyRuntime.faulthandler.stack
# define old_stack _PyRuntime.faulthandler.old_stack
#endif


Expand Down
6 changes: 0 additions & 6 deletions Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,6 @@ Modules/itertoolsmodule.c - tee_type -
Modules/itertoolsmodule.c - teedataobject_type -
Modules/itertoolsmodule.c - ziplongest_type -

##-----------------------
## state

Modules/faulthandler.c - stack -
Modules/faulthandler.c - old_stack -


##################################
## global non-objects to fix in builtin modules
Expand Down
0