diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-02-11 13:23:35 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-02-11 13:23:35 (GMT) |
commit | 7a5567a92cf0e0bcaae7dca8975328c9151fe1c7 (patch) | |
tree | 3ce30b7bf86bf423c9f5197ce361c1ec58b002d7 | |
parent | 8e36812e27f70bd6e4b3b85c9e9e858b0ac0df5e (diff) | |
download | cpython-7a5567a92cf0e0bcaae7dca8975328c9151fe1c7.zip cpython-7a5567a92cf0e0bcaae7dca8975328c9151fe1c7.tar.gz cpython-7a5567a92cf0e0bcaae7dca8975328c9151fe1c7.tar.bz2 |
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.
-rw-r--r-- | Modules/faulthandler.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index c17ffd8..01e7beb 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -911,12 +911,12 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args) } #if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION) -static void* -stack_overflow(void *min_sp, void *max_sp, size_t *depth) +static Py_uintptr_t +stack_overflow(Py_uintptr_t min_sp, Py_uintptr_t max_sp, size_t *depth) { /* allocate 4096 bytes on the stack at each call */ unsigned char buffer[4096]; - void *sp = &buffer; + Py_uintptr_t sp = (Py_uintptr_t)&buffer; *depth += 1; if (sp < min_sp || max_sp < sp) return sp; @@ -929,7 +929,8 @@ static PyObject * faulthandler_stack_overflow(PyObject *self) { size_t depth, size; - char *sp = (char *)&depth, *stop; + Py_uintptr_t sp = (Py_uintptr_t)&depth; + Py_uintptr_t stop; depth = 0; stop = stack_overflow(sp - STACK_OVERFLOW_MAX_SIZE, |