mirror of
https://github.com/python/cpython.git
synced 2025-11-15 00:00:00 +00:00
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.
This commit is contained in:
parent
7105319ada
commit
8b787964e0
2 changed files with 9 additions and 10 deletions
|
|
@ -0,0 +1,3 @@
|
||||||
|
Fix test_faulthandler on GCC 10. Use the "volatile" keyword in
|
||||||
|
``faulthandler._stack_overflow()`` to prevent tail call optimization on any
|
||||||
|
compiler, rather than relying on compiler specific pragma.
|
||||||
|
|
@ -1161,18 +1161,14 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
|
||||||
#if defined(FAULTHANDLER_USE_ALT_STACK)
|
#if defined(FAULTHANDLER_USE_ALT_STACK)
|
||||||
#define FAULTHANDLER_STACK_OVERFLOW
|
#define FAULTHANDLER_STACK_OVERFLOW
|
||||||
|
|
||||||
#ifdef __INTEL_COMPILER
|
static uintptr_t
|
||||||
/* Issue #23654: Turn off ICC's tail call optimization for the
|
|
||||||
* stack_overflow generator. ICC turns the recursive tail call into
|
|
||||||
* a loop. */
|
|
||||||
# pragma intel optimization_level 0
|
|
||||||
#endif
|
|
||||||
static
|
|
||||||
uintptr_t
|
|
||||||
stack_overflow(uintptr_t min_sp, uintptr_t max_sp, size_t *depth)
|
stack_overflow(uintptr_t min_sp, uintptr_t max_sp, size_t *depth)
|
||||||
{
|
{
|
||||||
/* allocate 4096 bytes on the stack at each call */
|
/* Allocate (at least) 4096 bytes on the stack at each call.
|
||||||
unsigned char buffer[4096];
|
|
||||||
|
bpo-23654, bpo-38965: use volatile keyword to prevent tail call
|
||||||
|
optimization. */
|
||||||
|
volatile unsigned char buffer[4096];
|
||||||
uintptr_t sp = (uintptr_t)&buffer;
|
uintptr_t sp = (uintptr_t)&buffer;
|
||||||
*depth += 1;
|
*depth += 1;
|
||||||
if (sp < min_sp || max_sp < sp)
|
if (sp < min_sp || max_sp < sp)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue