diff options
author | Victor Stinner <vstinner@python.org> | 2019-12-04 20:10:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-04 20:10:06 (GMT) |
commit | 8b787964e0a647caa0558b7c29ae501470d727d9 (patch) | |
tree | 0e1e3c90e4c14c5d7b6863e62a7af008c8f44a60 /Modules | |
parent | 7105319ada2e663659020cbe9fdf7ff38f421ab2 (diff) | |
download | cpython-8b787964e0a647caa0558b7c29ae501470d727d9.zip cpython-8b787964e0a647caa0558b7c29ae501470d727d9.tar.gz cpython-8b787964e0a647caa0558b7c29ae501470d727d9.tar.bz2 |
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.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/faulthandler.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index d128053..b19401e 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -1161,18 +1161,14 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args) #if defined(FAULTHANDLER_USE_ALT_STACK) #define FAULTHANDLER_STACK_OVERFLOW -#ifdef __INTEL_COMPILER - /* 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 +static uintptr_t stack_overflow(uintptr_t min_sp, uintptr_t max_sp, size_t *depth) { - /* allocate 4096 bytes on the stack at each call */ - unsigned char buffer[4096]; + /* Allocate (at least) 4096 bytes on the stack at each call. + + bpo-23654, bpo-38965: use volatile keyword to prevent tail call + optimization. */ + volatile unsigned char buffer[4096]; uintptr_t sp = (uintptr_t)&buffer; *depth += 1; if (sp < min_sp || max_sp < sp) |