diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-08-14 21:35:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-14 21:35:27 (GMT) |
commit | ac827edc493d3ac3f5b9b0cc353df1d4b418a9aa (patch) | |
tree | 14bfcfb0d36f6b4ba40a5765de967ccd890a89a5 | |
parent | 28146206578ebe1b84b48e6f255738a227058c04 (diff) | |
download | cpython-ac827edc493d3ac3f5b9b0cc353df1d4b418a9aa.zip cpython-ac827edc493d3ac3f5b9b0cc353df1d4b418a9aa.tar.gz cpython-ac827edc493d3ac3f5b9b0cc353df1d4b418a9aa.tar.bz2 |
bpo-21131: Fix faulthandler.register(chain=True) stack (GH-15276)
faulthandler now allocates a dedicated stack of SIGSTKSZ*2 bytes,
instead of just SIGSTKSZ bytes. Calling the previous signal handler
in faulthandler signal handler uses more than SIGSTKSZ bytes of stack
memory on some platforms.
-rw-r--r-- | Misc/NEWS.d/next/Library/2019-08-14-15-34-23.bpo-21131.0MMQRi.rst | 4 | ||||
-rw-r--r-- | Modules/faulthandler.c | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Misc/NEWS.d/next/Library/2019-08-14-15-34-23.bpo-21131.0MMQRi.rst b/Misc/NEWS.d/next/Library/2019-08-14-15-34-23.bpo-21131.0MMQRi.rst new file mode 100644 index 0000000..d330aca --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-08-14-15-34-23.bpo-21131.0MMQRi.rst @@ -0,0 +1,4 @@ +Fix ``faulthandler.register(chain=True)`` stack. faulthandler now allocates a +dedicated stack of ``SIGSTKSZ*2`` bytes, instead of just ``SIGSTKSZ`` bytes. +Calling the previous signal handler in faulthandler signal handler uses more +than ``SIGSTKSZ`` bytes of stack memory on some platforms. diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 2331051..5dbbcad 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -1325,7 +1325,11 @@ _PyFaulthandler_Init(int enable) * be able to allocate memory on the stack, even on a stack overflow. If it * fails, ignore the error. */ stack.ss_flags = 0; - stack.ss_size = SIGSTKSZ; + /* bpo-21131: allocate dedicated stack of SIGSTKSZ*2 bytes, instead of just + SIGSTKSZ bytes. Calling the previous signal handler in faulthandler + signal handler uses more than SIGSTKSZ bytes of stack memory on some + platforms. */ + stack.ss_size = SIGSTKSZ * 2; stack.ss_sp = PyMem_Malloc(stack.ss_size); if (stack.ss_sp != NULL) { err = sigaltstack(&stack, &old_stack); |