summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-08-31 06:24:50 (GMT)
committerGitHub <noreply@github.com>2021-08-31 06:24:50 (GMT)
commit8934bb0c3179e4c020cd6f08dea64bccbf56ffa2 (patch)
tree12b8f07b7a699016487c79422a5a73de88123731
parent29d97d17fb7adab3b0df9e178b73f70292d1cf64 (diff)
downloadcpython-8934bb0c3179e4c020cd6f08dea64bccbf56ffa2.zip
cpython-8934bb0c3179e4c020cd6f08dea64bccbf56ffa2.tar.gz
cpython-8934bb0c3179e4c020cd6f08dea64bccbf56ffa2.tar.bz2
bpo-38965: Fix faulthandler._stack_overflow() on GCC 10 (GH-17467) (GH-28079)
Use the "volatile" keyword to prevent tail call optimization on any compiler, rather than relying on compiler specific pragma. (cherry picked from commit 8b787964e0a647caa0558b7c29ae501470d727d9) Co-authored-by: Victor Stinner <vstinner@python.org> (cherry picked from commit 5044c889dfced2f43e2cccb673d889a4882f6b3b) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
-rw-r--r--Misc/NEWS.d/next/Tests/2019-12-04-17-08-55.bpo-38965.yqax3m.rst3
-rw-r--r--Modules/faulthandler.c16
2 files changed, 9 insertions, 10 deletions
diff --git a/Misc/NEWS.d/next/Tests/2019-12-04-17-08-55.bpo-38965.yqax3m.rst b/Misc/NEWS.d/next/Tests/2019-12-04-17-08-55.bpo-38965.yqax3m.rst
new file mode 100644
index 0000000..517a137
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2019-12-04-17-08-55.bpo-38965.yqax3m.rst
@@ -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.
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 890c645..3e0a7b1 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -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)