mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
(cherry picked from commit ac827edc49
)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
This commit is contained in:
parent
123f6c4914
commit
b8e682427a
2 changed files with 9 additions and 1 deletions
|
@ -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.
|
|
@ -1325,7 +1325,11 @@ _PyFaulthandler_Init(int enable)
|
||||||
* be able to allocate memory on the stack, even on a stack overflow. If it
|
* be able to allocate memory on the stack, even on a stack overflow. If it
|
||||||
* fails, ignore the error. */
|
* fails, ignore the error. */
|
||||||
stack.ss_flags = 0;
|
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);
|
stack.ss_sp = PyMem_Malloc(stack.ss_size);
|
||||||
if (stack.ss_sp != NULL) {
|
if (stack.ss_sp != NULL) {
|
||||||
err = sigaltstack(&stack, &old_stack);
|
err = sigaltstack(&stack, &old_stack);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue