torsava / rpms / python3

Forked from rpms/python3 6 years ago
Clone
Matej Stuchlik 6413bb1
Matej Stuchlik 6413bb1
# HG changeset patch
Matej Stuchlik 6413bb1
# User Victor Stinner <victor.stinner@gmail.com>
Matej Stuchlik 6413bb1
# Date 1423661015 -3600
Matej Stuchlik 6413bb1
# Node ID 689092296ad31951f8f919fc06b49450e648e93d
Matej Stuchlik 6413bb1
# Parent  645f3d750be139ce0198e15e221da07b22289a92
Matej Stuchlik 6413bb1
Issue #23433: Fix faulthandler._stack_overflow()
Matej Stuchlik 6413bb1
Matej Stuchlik 6413bb1
Fix undefined behaviour: don't compare pointers. Use Py_uintptr_t type instead
Matej Stuchlik 6413bb1
of void*. It fixes test_faulthandler on Fedora 22 which now uses GCC 5.
Matej Stuchlik 6413bb1
Matej Stuchlik 6413bb1
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
Matej Stuchlik 6413bb1
--- a/Modules/faulthandler.c
Matej Stuchlik 6413bb1
+++ b/Modules/faulthandler.c
Matej Stuchlik 6413bb1
@@ -911,12 +911,12 @@ faulthandler_fatal_error_py(PyObject *se
Matej Stuchlik 6413bb1
 }
Matej Stuchlik 6413bb1
 
Matej Stuchlik 6413bb1
 #if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
Matej Stuchlik 6413bb1
-static void*
Matej Stuchlik 6413bb1
-stack_overflow(void *min_sp, void *max_sp, size_t *depth)
Matej Stuchlik 6413bb1
+static Py_uintptr_t
Matej Stuchlik 6413bb1
+stack_overflow(Py_uintptr_t min_sp, Py_uintptr_t max_sp, size_t *depth)
Matej Stuchlik 6413bb1
 {
Matej Stuchlik 6413bb1
     /* allocate 4096 bytes on the stack at each call */
Matej Stuchlik 6413bb1
     unsigned char buffer[4096];
Matej Stuchlik 6413bb1
-    void *sp = &buffer;
Matej Stuchlik 6413bb1
+    Py_uintptr_t sp = (Py_uintptr_t)&buffer;
Matej Stuchlik 6413bb1
     *depth += 1;
Matej Stuchlik 6413bb1
     if (sp < min_sp || max_sp < sp)
Matej Stuchlik 6413bb1
         return sp;
Matej Stuchlik 6413bb1
@@ -929,7 +929,8 @@ static PyObject *
Matej Stuchlik 6413bb1
 faulthandler_stack_overflow(PyObject *self)
Matej Stuchlik 6413bb1
 {
Matej Stuchlik 6413bb1
     size_t depth, size;
Matej Stuchlik 6413bb1
-    char *sp = (char *)&depth, *stop;
Matej Stuchlik 6413bb1
+    Py_uintptr_t sp = (Py_uintptr_t)&depth;
Matej Stuchlik 6413bb1
+    Py_uintptr_t stop;
Matej Stuchlik 6413bb1
 
Matej Stuchlik 6413bb1
     depth = 0;
Matej Stuchlik 6413bb1
     stop = stack_overflow(sp - STACK_OVERFLOW_MAX_SIZE,
Matej Stuchlik 6413bb1