Skip to content

Commit 7a5567a

Browse files
committed
Issue #23433: Fix faulthandler._stack_overflow()
Fix undefined behaviour: don't compare pointers. Use Py_uintptr_t type instead of void*. It fixes test_faulthandler on Fedora 22 which now uses GCC 5.
1 parent 8e36812 commit 7a5567a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Modules/faulthandler.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,12 +911,12 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
911911
}
912912

913913
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
914-
static void*
915-
stack_overflow(void *min_sp, void *max_sp, size_t *depth)
914+
static Py_uintptr_t
915+
stack_overflow(Py_uintptr_t min_sp, Py_uintptr_t max_sp, size_t *depth)
916916
{
917917
/* allocate 4096 bytes on the stack at each call */
918918
unsigned char buffer[4096];
919-
void *sp = &buffer;
919+
Py_uintptr_t sp = (Py_uintptr_t)&buffer;
920920
*depth += 1;
921921
if (sp < min_sp || max_sp < sp)
922922
return sp;
@@ -929,7 +929,8 @@ static PyObject *
929929
faulthandler_stack_overflow(PyObject *self)
930930
{
931931
size_t depth, size;
932-
char *sp = (char *)&depth, *stop;
932+
Py_uintptr_t sp = (Py_uintptr_t)&depth;
933+
Py_uintptr_t stop;
933934

934935
depth = 0;
935936
stop = stack_overflow(sp - STACK_OVERFLOW_MAX_SIZE,

0 commit comments

Comments
 (0)