8000 [3.6] bpo-38965: Fix faulthandler._stack_overflow() on GCC 10 (GH-17467) by miss-islington · Pull Request #28079 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.6] bpo-38965: Fix faulthandler._stack_overflow() on GCC 10 (GH-17467) #28079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Misc/NEWS.d/next/Tests/2019-12-04-17-08-55.bpo-38965.yqax3m.rst
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 6 additions & 10 deletions Modules/faulthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,18 +1091,14 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
#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)
Expand Down
0