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

Skip to content

Commit 8b78796

Browse files
authored
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.
1 parent 7105319 commit 8b78796

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
@@ -1161,18 +1161,14 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
11611161
#if defined(FAULTHANDLER_USE_ALT_STACK)
11621162
#define FAULTHANDLER_STACK_OVERFLOW
11631163

1164-
#ifdef __INTEL_COMPILER
1165-
/* Issue #23654: Turn off ICC's tail call optimization for the
1166-
* stack_overflow generator. ICC turns the recursive tail call into
1167-
* a loop. */
1168-
# pragma intel optimization_level 0
1169-
#endif
1170-
static
1171-
uintptr_t
1164+
static uintptr_t
11721165
stack_overflow(uintptr_t min_sp, uintptr_t max_sp, size_t *depth)
11731166
{
1174-
/* allocate 4096 bytes on the stack at each call */
1175-
unsigned char buffer[4096];
1167+
/* Allocate (at least) 4096 bytes on the stack at each call.
1168+
1169+
bpo-23654, bpo-38965: use volatile keyword to prevent tail call
1170+
optimization. */
1171+
volatile unsigned char buffer[4096];
11761172
uintptr_t sp = (uintptr_t)&buffer;
11771173
*depth += 1;
11781174
if (sp < min_sp || max_sp < sp)

0 commit comments

Comments
 (0)
0