8000 bpo-38965: Fix faulthandler._stack_overflow() on GCC 10 (GH-17467) · python/cpython@5044c88 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5044c88

Browse files
bpo-38965: Fix faulthandler._stack_overflow() on GCC 10 (GH-17467)
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>
1 parent e0f148e commit 5044c88

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
@@ -1094,18 +1094,14 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
10941094
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
10951095
#define FAULTHANDLER_STACK_OVERFLOW
10961096

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

0 commit comments

Comments
 (0)
0