Skip to content

Commit 8934bb0

Browse files
bpo-38965: Fix faulthandler._stack_overflow() on GCC 10 (GH-17467) (GH-28079)
Use the "volatile" keyword to prevent tail call optimization on any compiler, rather than relying on compiler specific pragma. (cherry picked from commit 8b78796) Co-authored-by: Victor Stinner <vstinner@python.org> (cherry picked from commit 5044c88) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
1 parent 29d97d1 commit 8934bb0

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix test_faulthandler on GCC 10. Use the "volatile" keyword in
2+
``faulthandler._stack_overflow()`` to prevent tail call optimization on any
3+
compiler, rather than relying on compiler specific pragma.

Modules/faulthandler.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,18 +1091,14 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
10911091
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
10921092
#define FAULTHANDLER_STACK_OVERFLOW
10931093

1094-
#ifdef __INTEL_COMPILER
1095-
/* Issue #23654: Turn off ICC's tail call optimization for the
1096-
* stack_overflow generator. ICC turns the recursive tail call into
1097-
* a loop. */
1098-
# pragma intel optimization_level 0
1099-
#endif
1100-
static
1101-
uintptr_t
1094+
static uintptr_t
11021095
stack_overflow(uintptr_t min_sp, uintptr_t max_sp, size_t *depth)
11031096
{
1104-
/* allocate 4096 bytes on the stack at each call */
1105-
unsigned char buffer[4096];
1097+
/* Allocate (at least) 4096 bytes on the stack at each call.
1098+
1099+
bpo-23654, bpo-38965: use volatile keyword to prevent tail call
1100+
optimization. */
1101+
volatile unsigned char buffer[4096];
11061102
uintptr_t sp = (uintptr_t)&buffer;
11071103
*depth += 1;
11081104
if (sp < min_sp || max_sp < sp)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy