]> granicus.if.org Git - python/commitdiff
bpo-21131: Fix faulthandler.register(chain=True) stack (GH-15276)
authorVictor Stinner <vstinner@redhat.com>
Wed, 14 Aug 2019 21:35:27 +0000 (23:35 +0200)
committerGitHub <noreply@github.com>
Wed, 14 Aug 2019 21:35:27 +0000 (23:35 +0200)
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.

Misc/NEWS.d/next/Library/2019-08-14-15-34-23.bpo-21131.0MMQRi.rst [new file with mode: 0644]
Modules/faulthandler.c

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 (file)
index 0000000..d330aca
--- /dev/null
@@ -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.
index 2331051f7907a888886b929111210782c5b7860d..5dbbcad057e643ed3a4b377c7ebce2d049e6aa61 100644 (file)
@@ -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);